summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/tmux-cycle-a-session29
-rw-r--r--tmux/tmux.conf5
2 files changed, 34 insertions, 0 deletions
diff --git a/scripts/tmux-cycle-a-session b/scripts/tmux-cycle-a-session
new file mode 100755
index 0000000..2b4557a
--- /dev/null
+++ b/scripts/tmux-cycle-a-session
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Cycle through tmux sessions whose name starts with "A-".
+# Usage: tmux-cycle-a-session next|prev
+set -euo pipefail
+
+direction="${1:-next}"
+
+mapfile -t sessions < <(tmux list-sessions -F '#S' | grep '^A-' | sort)
+[ "${#sessions[@]}" -eq 0 ] && exit 0
+
+cur=$(tmux display-message -p '#S')
+
+# Find current index (0-based); -1 if not found
+idx=-1
+for i in "${!sessions[@]}"; do
+ if [ "${sessions[$i]}" = "$cur" ]; then
+ idx=$i
+ break
+ fi
+done
+
+n="${#sessions[@]}"
+case "$direction" in
+ next) target_idx=$(( idx < 0 ? 0 : (idx + 1) % n )) ;;
+ prev) target_idx=$(( idx < 0 ? n - 1 : (idx - 1 + n) % n )) ;;
+ *) echo "usage: $0 next|prev" >&2; exit 2 ;;
+esac
+
+tmux switch-client -t "${sessions[$target_idx]}"
diff --git a/tmux/tmux.conf b/tmux/tmux.conf
index 8147790..e932031 100644
--- a/tmux/tmux.conf
+++ b/tmux/tmux.conf
@@ -39,6 +39,11 @@ bind-key T choose-tree
# agent workload). Pressing it again strips the prefix.
bind-key @ run-shell 'cur=$(tmux display-message -p "#S"); case "$cur" in A-*) tmux rename-session "${cur#A-}" ;; *) tmux rename-session "A-$cur" ;; esac'
+# Cycle through sessions whose name starts with "A-" (agent workloads).
+# Mirrors the default Prefix+( / Prefix+) bindings but filtered to A- sessions.
+bind-key O run-shell 'tmux-cycle-a-session next'
+bind-key I run-shell 'tmux-cycle-a-session prev'
+
set-option -g pane-active-border-style fg=magenta,bold
set -g status-right '#{@hexai_status} #[fg=colour8]| %H:%M'