SHA256
1
0

Refactor to reduce config in group_vars

This commit is contained in:
2026-01-29 23:34:14 -05:00
parent 1b0c289b9b
commit 6d38e1dc5c
76 changed files with 1900 additions and 2119 deletions

View File

@@ -1,11 +1,20 @@
#!/usr/bin/env bash
# Open a tiled tmux window with one pane per host each in its own tmux session.
# The local session is always the last (active) pane.
set -euo pipefail
# Accept hostnames from command-line arguments
if (( $# > 0 )); then
HOSTS=("$@")
else
# Default hostnames in the desired pane order
HOSTS=(
workstation
laptop
)
fi
# Configuration (override with env vars if desired)
HOSTS=(workstation laptop) # hosts in pane order
REMOTE_SESSION=${REMOTE_SESSION:-main} # tmux session on remotes
SYNCHRONIZE=${SYNCHRONIZE:-1} # 1 = broadcast keystrokes
INCLUDE_LOCAL=${INCLUDE_LOCAL:-1} # 0 = skip local host
@@ -56,7 +65,8 @@ open_cmd() {
printf 'tmux -L %q new -A -s %q' "${SESSION}_local" "$REMOTE_SESSION"
fi
else
printf 'ssh -t %q tmux new -A -s %q' "$tgt" "$REMOTE_SESSION"
# SSH with keepalive settings for faster broken pipe detection
printf 'ssh -o ServerAliveInterval=20 -o ServerAliveCountMax=3 -t %q tmux new -A -s %q' "$tgt" "$REMOTE_SESSION"
fi
}
@@ -74,8 +84,8 @@ tmux select-layout -t "$SESSION:0" tiled
# Keep panes visible when commands exit
tmux set-option -t "$SESSION:0" remain-on-exit on
# Auto-respawn any pane whose command dies
tmux set-hook -t "$SESSION" pane-died "run-shell 'tmux respawn-pane -k -t #{pane_id}'"
# Reconnect dead panes when user focuses on them
tmux set-hook -t "$SESSION" pane-focus-in "if -F '#{pane_dead}' 'respawn-pane -k -t #{pane_id}'"
# Activate the last pane (local host)
local_index=$(( ${#TARGETS[@]} - 1 ))