summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdotfiles/common/.local/bin/aix15
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