summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-14 16:22:02 -0600
committerCraig Jennings <c@cjennings.net>2026-02-14 16:22:02 -0600
commitf9a4a8bb89ece9901ace91f2f5bdaa3bae947d5e (patch)
tree33027b85d730c87a677432c21f720d424e2a80a9
parent2dd49a1526abcc78e9d1548457ae306061ad365f (diff)
fix(aix): classify windows by project name instead of shell regex
sort_windows now builds known project basenames from candidate dirs and treats everything else as non-project. Prevents TUI apps (mc, ranger, htop) from being misclassified as project windows.
-rwxr-xr-xdotfiles/common/.local/bin/aix36
1 files changed, 28 insertions, 8 deletions
diff --git a/dotfiles/common/.local/bin/aix b/dotfiles/common/.local/bin/aix
index b9d9e69..ad40d84 100755
--- a/dotfiles/common/.local/bin/aix
+++ b/dotfiles/common/.local/bin/aix
@@ -57,15 +57,35 @@ build_candidates() {
fi
}
-# Sort windows: shells at base-index, projects alphabetically after
+# Sort windows: non-project windows at base-index, projects alphabetically after
sort_windows() {
- local windows shells projects base_idx
+ local windows others projects base_idx project_names
base_idx=$(tmux show-option -gv base-index 2>/dev/null || echo 0)
windows=$(tmux list-windows -t "$SESSION" -F '#{window_name}'$'\t''#{window_id}')
- shells=$(echo "$windows" | grep -iE '^(bash|zsh|fish|sh)'$'\t' | sort -t$'\t' -k1,1f)
- projects=$(echo "$windows" | grep -viE '^(bash|zsh|fish|sh)'$'\t' | sort -t$'\t' -k1,1f)
+
+ # Build list of known project basenames from candidate directories
+ build_candidates
+ project_names=""
+ for c in "${candidates[@]}"; do
+ project_names+="$(basename "${c/#\~/$HOME}")"$'\n'
+ done
+
+ # Classify: windows matching a project basename are projects, rest are non-project
+ others=""
+ projects=""
+ while IFS=$'\t' read -r wname wid; do
+ [ -z "$wname" ] && continue
+ if echo "$project_names" | grep -qxF "$wname"; then
+ projects+="${wname}"$'\t'"${wid}"$'\n'
+ else
+ others+="${wname}"$'\t'"${wid}"$'\n'
+ fi
+ done <<<"$windows"
+ others=$(echo -n "$others" | sort -t$'\t' -k1,1f)
+ projects=$(echo -n "$projects" | sort -t$'\t' -k1,1f)
+
local all
- all=$(printf '%s\n' "$shells" "$projects" | sed '/^$/d')
+ all=$(printf '%s\n' "$others" "$projects" | sed '/^$/d')
# Move all to high temp indices to avoid collisions
local i=900
@@ -74,13 +94,13 @@ sort_windows() {
((i++))
done <<<"$all"
- # Place shells at base-index, projects contiguously after
+ # Place non-project windows at base-index, projects contiguously after
i=$base_idx
- if [ -n "$shells" ]; then
+ if [ -n "$others" ]; then
while IFS=$'\t' read -r _name wid; do
tmux move-window -s "$wid" -t "$SESSION:$i"
((i++))
- done <<<"$shells"
+ done <<<"$others"
fi
if [ -n "$projects" ]; then
while IFS=$'\t' read -r _name wid; do