About tmux
A skill for controlling interactive terminal applications through tmux. It is for developers who need to send commands and keystrokes, inspect output, or manage remote terminal sessions, and includes helper scripts for session lookup and text polling.
Key features
- 01Create and control tmux sessions
- 02Send terminal commands and keystrokes
- 03Capture terminal output
- 04Run commands remotely over SSH
- 05Use session lookup and text-polling scripts
Use cases
- 01Run Python, Node, or psql REPLs
- 02Debug with gdb or lldb in a terminal
- 03Control CLIs that require a TTY
- 04Observe remote command output over SSH
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ connorads/ dotfiles --skill tmuxAfter installing, type/tmuxin Claude Code to confirm it loaded.
Bundled filesscripts/find-sessions.shscripts/wait-for-text.sh
Details
From the project READMEtmux Skill
Use tmux to control interactive terminal applications by sending keystrokes and capturing output.
When to Use
- Running interactive REPLs (python, node, psql)
- Debugging with gdb/lldb
- Any CLI that requires TTY interaction
- Remote execution where you need to observe output
Core Pattern
# Create session
tmux new-session -d -s "$SESSION" -x 120 -y 40
# Send commands
tmux send-keys -t "$SESSION" "python3" Enter
# Capture output
tmux capture-pane -t "$SESSION" -p
# Wait for prompt (poll)
for i in {1..30}; do
output=$(tmux capture-pane -t "$SESSION" -p)
if echo "$output" | grep -q ">>>"; then break; fi
sleep 0.5
done
# Cleanup
tmux kill-session -t "$SESSION"
Remote Execution (Codespaces/SSH)
For mise-installed tools, wrap in zsh:
# Non-interactive (won't hang)
ssh host 'zsh -c "source ~/.zshrc; tmux new-session -d -s mysession; tmux send-keys -t mysession python Enter"'
# Interactive (for tmux attach) - needs TTY
ssh host -t 'zsh -ilc "tmux attach -t mysession"'
Critical: Use zsh -c "source ~/.zshrc; ..." not zsh -lc to avoid hangs.
User Notification
After starting a session, ALWAYS print:
To monitor: tmux attach -t $SESSION
To capture: tmux capture-pane -t $SESSION -p
Tips
- Use
-x 120 -y 40for consistent pane size - Poll with
capture-pane -prather thanwait-for - Send literal text with
-lflag to avoid shell expansion - Control keys:
C-c(interrupt),C-d(EOF),Escape - For Python REPL: set
PYTHON_BASIC_REPL=1to avoid fancy console interference
Helper Scripts
wait-for-text.sh
Poll tmux pane for a text pattern with timeout:
scripts/wait-for-text.sh -t session:0.0 -p '^>>>' -T 15
find-sessions.sh
List tmux sessions, optionally filtered:
scripts/find-sessions.sh -q claude # filter by name
scripts/find-sessions.sh --all # all sessions
Comments
Markdown supported