summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-31 19:20:47 +0300
committerPaul Buetow <paul@buetow.org>2026-05-31 19:20:47 +0300
commit7f3b3d58527db7a5e6a167555e1526d6836d7fe4 (patch)
tree0b268a0150c1abef50f89affba84a23665504f78 /scripts
parentaca4f43dc309b4d4a64d52aebcb28b1951feb146 (diff)
tmux: add Prefix+I / Prefix+O to cycle A- sessions
Mirrors the default Prefix+( / Prefix+) bindings but filtered to sessions whose name starts with the 'A-' agent-workload prefix. Logic lives in scripts/tmux-cycle-a-session. Amp-Thread-ID: https://ampcode.com/threads/T-019e7daf-7dbc-720d-a818-d971666b01e0 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tmux-cycle-a-session29
1 files changed, 29 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]}"