| name | tmux |
| description | Remote-control tmux sessions for interactive CLIs |
| always | false |
| triggers | ["tmux","terminal","session","multiplexer"] |
| requires | ["bin:tmux"] |
| metadata | {"pocketrb":{"emoji":"🧵","os":["darwin","linux"]}} |
Tmux Skill
Control tmux sessions via socket for isolated agent workspaces. This allows running and interacting with persistent terminal sessions.
Socket Setup
Use a dedicated socket directory to avoid conflicts:
SOCKET_DIR="${POCKETRB_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/pocketrb-tmux-sockets}"
mkdir -p "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/pocketrb.sock"
Basic Commands
Session Management
tmux -S "$SOCKET" new-session -d -s mysession
tmux -S "$SOCKET" new-session -d -s mysession "irb"
tmux -S "$SOCKET" list-sessions
tmux -S "$SOCKET" kill-session -t mysession
tmux -S "$SOCKET" attach -t mysession
Sending Commands
tmux -S "$SOCKET" send-keys -t mysession "ls -la" Enter
tmux -S "$SOCKET" send-keys -t mysession -l "some text"
tmux -S "$SOCKET" send-keys -t mysession C-c
tmux -S "$SOCKET" send-keys -t mysession C-d
tmux -S "$SOCKET" send-keys -t mysession Up
Capturing Output
tmux -S "$SOCKET" capture-pane -p -t mysession
tmux -S "$SOCKET" capture-pane -p -J -t mysession -S -200
tmux -S "$SOCKET" capture-pane -p -t mysession > output.txt
Common Patterns
Run Command and Get Output
tmux -S "$SOCKET" send-keys -t mysession "ruby script.rb" Enter
sleep 2
tmux -S "$SOCKET" capture-pane -p -J -t mysession -S -50
Interactive Ruby/IRB Session
tmux -S "$SOCKET" new-session -d -s ruby "irb"
tmux -S "$SOCKET" send-keys -t ruby "require 'pathname'" Enter
tmux -S "$SOCKET" send-keys -t ruby "puts Pathname.pwd" Enter
sleep 1
tmux -S "$SOCKET" capture-pane -p -t ruby
SSH Session
tmux -S "$SOCKET" new-session -d -s remote "ssh user@host"
sleep 3
tmux -S "$SOCKET" send-keys -t remote "ls -la" Enter
Tips
- Use
-l flag with send-keys for literal text to avoid interpretation
- The
-J flag in capture-pane joins wrapped lines
- Use
-S -N in capture-pane to capture last N lines of history
- Clean up sessions when done to avoid resource leaks
- Use unique session names to avoid conflicts