| name | tmux |
| description | Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output. |
| emoji | 🧵 |
| requires | {"bins":["tmux"]} |
| os | ["darwin","linux"] |
tmux Skill
Use tmux only when you need an interactive TTY. Prefer the shell tool for non-interactive tasks.
When to use
- Running interactive CLIs (python REPL, node REPL, etc.)
- Long-running processes that need monitoring
- Parallel task execution with multiple sessions
- Any command that requires a persistent terminal
Quickstart (isolated socket)
SOCKET_DIR="${TMPDIR:-/tmp}/chatdock-tmux"
mkdir -p "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/chatdock.sock"
SESSION=chatdock-main
tmux -S "$SOCKET" new -d -s "$SESSION" -n shell
tmux -S "$SOCKET" send-keys -t "$SESSION":0.0 -- 'echo Hello World' Enter
tmux -S "$SOCKET" capture-pane -p -J -t "$SESSION":0.0 -S -200
After starting a session, always provide monitor commands to the user:
To monitor:
tmux -S "$SOCKET" attach -t "$SESSION"
tmux -S "$SOCKET" capture-pane -p -J -t "$SESSION":0.0 -S -200
Socket convention
- Default socket:
$TMPDIR/chatdock-tmux/chatdock.sock
- Use a consistent socket path for all ChatDock sessions
Targeting panes
Target format: session:window.pane (defaults to :0.0)
tmux -S "$SOCKET" list-sessions
tmux -S "$SOCKET" list-panes -a
Sending input safely
tmux -S "$SOCKET" send-keys -t target -l -- "$cmd"
tmux -S "$SOCKET" send-keys -t target -- "ls -la" Enter
tmux -S "$SOCKET" send-keys -t target C-c
tmux -S "$SOCKET" send-keys -t target C-d
Watching output
tmux -S "$SOCKET" capture-pane -p -J -t target -S -200
while ! tmux -S "$SOCKET" capture-pane -p -t target | grep -q "pattern"; do
sleep 0.5
done
echo "Pattern found!"
Running Python REPLs
For Python REPLs, set PYTHON_BASIC_REPL=1 to avoid readline issues:
tmux -S "$SOCKET" send-keys -t "$SESSION":0.0 -- 'PYTHON_BASIC_REPL=1 python3 -q' Enter
Parallel execution (multiple agents)
SOCKET="${TMPDIR:-/tmp}/multi-agent.sock"
for i in 1 2 3; do
tmux -S "$SOCKET" new-session -d -s "task-$i"
done
tmux -S "$SOCKET" send-keys -t task-1 "cd /project1 && npm test" Enter
tmux -S "$SOCKET" send-keys -t task-2 "cd /project2 && npm test" Enter
tmux -S "$SOCKET" send-keys -t task-3 "cd /project3 && npm test" Enter
for sess in task-1 task-2 task-3; do
if tmux -S "$SOCKET" capture-pane -p -t "$sess" -S -3 | grep -q "\\$"; then
echo "$sess: DONE"
else
echo "$sess: Running..."
fi
done
Cleanup
tmux -S "$SOCKET" kill-session -t "$SESSION"
tmux -S "$SOCKET" kill-server
rm -f "$SOCKET"
Windows/WSL Note
This skill requires macOS or Linux. On Windows, use WSL and install tmux inside WSL.