| name | tmux-helper |
| description | Interact with tmux sessions, windows, and panes. Use when the user mentions tmux, dev servers, checking logs in panes, restarting services, or running commands in background terminals. Also covers tmuxinator for session management. |
tmux-helper
Reference for interacting with tmux from within an agent session.
Reading Pane Output
Always use capture-pane to read what is currently visible in a pane:
tmux capture-pane -t 0:1.0 -p
tmux capture-pane -t 0:1.0 -p -S -100
tmux capture-pane -t 0:1.0 -p -S -
The -p flag prints to stdout instead of a buffer. Without it nothing is returned.
Listing State
tmux list-sessions
tmux list-windows
tmux list-windows -t mysession
tmux list-panes -t mysession:1
tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index} #{pane_current_command} #{pane_width}x#{pane_height}"
Sending Commands to Panes
tmux send-keys -t 0:1.0 "npm run dev" C-m
tmux send-keys -t 0:1.0 C-c
tmux send-keys -t 0:1.0 C-c && sleep 0.5 && tmux send-keys -t 0:1.0 "npm run dev" C-m
Managing Panes and Windows
tmux kill-pane -t 0:1.2
tmux kill-window -t 0:1
tmux split-window -t 0:1 -v
tmux split-window -t 0:1 -h
tmux new-window -t mysession
tmux rename-window -t 0:1 "workers"
Target Format
The -t target format is session:window.pane. Parts are optional:
0 -- session 0, current window, current pane
0:1 -- session 0, window 1, current pane
0:1.2 -- session 0, window 1, pane 2
mysession:workers -- named session and named window
tmuxinator
The user uses tmuxinator for project-specific layouts. Config files live in either ~/.tmuxinator/ or .tmuxinator/ in the project root.
tmuxinator start -p .tmuxinator/web.yml
tmuxinator start web
tmuxinator stop web
tmuxinator list
Common Patterns
Restart a dev server in a pane
tmux send-keys -t 0:1.0 C-c
sleep 0.5
tmux send-keys -t 0:1.0 "pnpm dev" C-m
Check if a server is running
tmux capture-pane -t 0:1.0 -p -S -20
Look for "listening on" or error output in the captured text.
Run a command without disturbing the pane
If the pane has an idle shell, send the command. If a process is running, either use a different pane or kill the process first.
Rules
- Never use
nohup or background processes. tmux panes are the designated way to run long-lived processes.
- Always confirm which pane has which server before sending commands. Use
list-panes first.
- When the user says "check tmux" or "see tmux", capture pane output and report what you see.
- When the user says "run in tmux", send the command to an appropriate idle pane.