diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-13 13:46:55 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-13 13:46:55 -0600 |
| commit | 0a31061eb674661fa3cb67725b60c486063634b4 (patch) | |
| tree | 6e6ce509f11cffad5dc684f98c776b6d86b30468 /dotfiles/common/.local/bin | |
| parent | 4c22ea608b14552e401abf6e2726404f8a457bd8 (diff) | |
fix(aix): respect tmux base-index for shell window placement
Shell window was intermittently shifting to index 1 because sort_windows
hardcoded index 0, which conflicts with base-index=1 and renumber-windows.
Diffstat (limited to 'dotfiles/common/.local/bin')
| -rwxr-xr-x | dotfiles/common/.local/bin/aix | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/dotfiles/common/.local/bin/aix b/dotfiles/common/.local/bin/aix index ecbb24c..27c1638 100755 --- a/dotfiles/common/.local/bin/aix +++ b/dotfiles/common/.local/bin/aix @@ -57,9 +57,10 @@ build_candidates() { fi } -# Sort windows alphabetically by name, shells last +# Sort windows: shells at base-index, projects alphabetically after sort_windows() { - local windows shells projects + local windows shells projects base_idx + 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) @@ -73,15 +74,14 @@ sort_windows() { ((i++)) done <<<"$all" - # Place shells at 0, projects from 1 - i=0 + # Place shells at base-index, projects contiguously after + i=$base_idx if [ -n "$shells" ]; then while IFS=$'\t' read -r _name wid; do tmux move-window -s "$wid" -t "$SESSION:$i" ((i++)) done <<<"$shells" fi - i=1 if [ -n "$projects" ]; then while IFS=$'\t' read -r _name wid; do tmux move-window -s "$wid" -t "$SESSION:$i" @@ -164,7 +164,8 @@ for entry in "${selected[@]:1}"; do create_window "$dir" "$name" > /dev/null done -# Sort windows and select first +# Sort windows and select first project sort_windows -tmux select-window -t "$SESSION:1" +base_idx=$(tmux show-option -gv base-index 2>/dev/null || echo 0) +tmux select-window -t "$SESSION:$base_idx" attach_session |
