Loading...
Loading...
Control tmux sessions, windows, and panes via the tmux CLI. Covers session management, window/pane operations, sending keys, reading output, and pane decoration.
npx skill4agent add halfwhey/skills tmuxtmuxpane_id# From a user-supplied number (e.g. "pane 1" in the current window)
PANE_ID=$(tmux display-message -t :.1 -p '#{pane_id}') # → %42
# From a full target
PANE_ID=$(tmux display-message -t 0:2.1 -p '#{pane_id}')
# pane_id is valid as a -t target for all pane-level commands
tmux send-keys -t %42 "echo hello" Enter
tmux capture-pane -t %42 -p
tmux select-pane -t %42 -T "my title"
tmux kill-pane -t %42pane_idpane_id# List all panes in the current window (excluding yourself)
tmux list-panes -F '#{pane_id} #{pane_current_command}' | grep -v "^$TMUX_PANE "
# "The other pane" / "the only other pane" — works when there are exactly 2 panes
PANE_ID=$(tmux list-panes -F '#{pane_id}' | grep -v "^$TMUX_PANE$")
# "The pane running vim"
PANE_ID=$(tmux list-panes -F '#{pane_id} #{pane_current_command}' | grep vim | awk '{print $1}')$TMUX_PANEtmux display-panes -d 5000:.NPANE_ID=$(tmux display-message -t :.1 -p '#{pane_id}')${CLAUDE_SKILL_DIR}/scripts/read-tmuxcapture-pane${CLAUDE_SKILL_DIR}/scripts/read-tmux %42 # delta mode (default) — for shell output
${CLAUDE_SKILL_DIR}/scripts/read-tmux --tui %42 # TUI mode — diff of changed screen regions
${CLAUDE_SKILL_DIR}/scripts/read-tmux --full %42 # TUI mode — always full screen (no diff)(no new output)--tui(no changes on screen)/tmp/tmux-skill/<pane_id>/position ← line counter for delta mode
tui_prev ← last TUI capture for diffing${CLAUDE_SKILL_DIR}/scripts/read-tmux${CLAUDE_SKILL_DIR}/scripts/send-tmuxtmux set-option -p -t %42 -u pane-border-status 2>/dev/null || true
tmux set-option -p -t %42 -u pane-border-format 2>/dev/null || truesend-tmuxtmux send-keys# Run a command
${CLAUDE_SKILL_DIR}/scripts/send-tmux %42 "npm test" Enter
# Interrupt
${CLAUDE_SKILL_DIR}/scripts/send-tmux %42 C-c
# Send EOF / exit shell
${CLAUDE_SKILL_DIR}/scripts/send-tmux %42 C-d
# Quit a pager
${CLAUDE_SKILL_DIR}/scripts/send-tmux %42 q# List
tmux list-sessions
tmux list-sessions -F '#{session_name} (#{session_windows} windows)'
# Create (detached)
tmux new-session -d -s <name> [-c <start-dir>]
# Rename
tmux rename-session -t <old> <new>
# Kill
tmux kill-session -t <name>
# Check existence
tmux has-session -t <name> 2>/dev/null && echo exists# List
tmux list-windows -t <session>
tmux list-windows -t <session> -F '#{window_index}: #{window_name}'
# Create
tmux new-window -t <session> -n <name> [-c <dir>]
# Rename
tmux rename-window -t <session>:<index> <new-name>
# Move to another session or index
tmux move-window -s <session>:<index> -t <dst-session>:<new-index>
# Swap two windows
tmux swap-window -s <session>:<a> -t <session>:<b>
# Kill
tmux kill-window -t <session>:<index># List (resolve pane_id for any pane you'll interact with)
tmux list-panes -t <session>:<window> -F '#{pane_index} #{pane_id} #{pane_current_command}'
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command}'
# Create — split relative to Claude's own pane so it opens in the right window.
# $TMUX_PANE is Claude's pane_id, set automatically by tmux.
# -P -F prints the new pane's id directly.
PANE_ID=$(tmux split-window -h -t "$TMUX_PANE" -P -F '#{pane_id}') # side by side
PANE_ID=$(tmux split-window -v -t "$TMUX_PANE" -P -F '#{pane_id}') # top/bottom
# Rename (sets title shown in pane border)
tmux select-pane -t %42 -T <title>
# Move pane to another window
tmux move-pane -s %42 -t <dst-session>:<dst-window>
# Break pane out into its own window
tmux break-pane -t %42 -n <new-window-name>
# Join a window into another as a pane
tmux join-pane -s <src-window> -t <dst-window>
# Swap two panes
tmux swap-pane -s %42 -t %99
# Kill
tmux kill-pane -t %42# Pane properties
tmux display-message -t %42 -p '#{pane_id}'
tmux display-message -t %42 -p '#{pane_current_command}'
tmux display-message -t %42 -p '#{pane_current_path}'
tmux display-message -t %42 -p '#{pane_pid}'
# Useful format variables
# #{pane_id} unique pane identifier (%42)
# #{pane_index} position within window (can be reused after kill)
# #{pane_current_command} process running in pane
# #{pane_current_path} working directory
# #{pane_pid} PID of pane shell
# #{session_name} session name
# #{window_index} window number
# #{window_name} window name${CLAUDE_SKILL_DIR}/scripts/send-tmux %42 "make build && echo __DONE__" Enter
while ! ${CLAUDE_SKILL_DIR}/scripts/read-tmux %42 | grep -q "__DONE__"; do sleep 0.5; doneWINDOW=$(tmux new-window -t myproject -n build -P -F '#{window_index}')
PANE_ID=$(tmux display-message -t "myproject:${WINDOW}.0" -p '#{pane_id}')
tmux select-pane -t "$PANE_ID" -T "● claude"
tmux send-keys -t "$PANE_ID" "make build" Entertmux send-keys -t %42 C-c
sleep 0.2
tmux send-keys -t %42 "make build" Enter