Tmux Ops
Guide agents to reliably inspect tmux state, target the correct pane, and send keys.
Quick start
Heuristic: Most of the time, the pane you need is in the current tmux window. Start by inspecting panes in the current window; only broaden to all windows (-a) if you don't find the right process/title.
# List all panes with IDs
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command} #{pane_title}'
# Send keys to a pane
tmux send-keys -t %3 "echo hello" C-m
# Capture recent output from a pane
tmux capture-pane -t %3 -p -S -200
Workflow
- Identify target pane
# Start with panes in the current window (most common case)
tmux display-message -p '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command} #{pane_title}'
tmux list-panes -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command} #{pane_title}'
# Fallback: search across all windows/sessions
tmux list-sessions
tmux list-windows -a -F '#{session_name}:#{window_index} #{window_name}'
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command} #{pane_title}'
- Confirm focus (optional)
tmux display-message -p -t %3 '#{session_name}:#{window_index}.#{pane_index} #{pane_id} #{pane_current_command}'
- Send keys
tmux send-keys -t %3 "<command>" C-m
Common operations
- Start a new session
tmux new-session -d -s work
- Create or split panes
tmux split-window -t work:0 -h
tmux split-window -t work:0 -v
- Select a pane
tmux select-pane -t %3
- Stop the process in a pane (graceful)
tmux send-keys -t %3 C-c
- Close a pane
tmux kill-pane -t %3
- Capture logs
tmux capture-pane -t %3 -p -S -200
Safety rules
- Always list panes and confirm the target pane ID before sending destructive keys.
- Prefer
C-cto stop a process beforekill-pane. - Avoid
kill-sessionunless the user explicitly asks.
Output guidance
- Return concise summaries: target pane ID, action taken, and any captured output snippets.
- When searching, state whether you checked the current window first; only list
-aresults if needed. - If the target pane is ambiguous, ask the user to choose from the pane list.
