From tmux-session-tools
Use this skill when users mention "tmux", "tmux pane", "tmux window", "tmux session", "background terminal", "parallel terminal", or when users need to run commands in separate terminals, capture output from other panes, or manage multiple Claude Code sessions in tmux.
How this skill is triggered — by the user, by Claude, or both
Slash command
/tmux-session-tools:tmuxThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reference for tmux commands to manage multiple terminals, run background processes, and capture output from other panes.
Reference for tmux commands to manage multiple terminals, run background processes, and capture output from other panes.
Check if running inside tmux before using tmux commands:
# $TMUX is set when inside tmux (contains socket path)
if [ -n "$TMUX" ]; then
echo "Inside tmux"
fi
# $TMUX_PANE contains current pane ID (e.g., %0)
echo $TMUX_PANE
# Create new window in current session
tmux new-window
# Create with name
tmux new-window -n "build"
# Create with working directory
tmux new-window -c "/path/to/project"
# Create and run command
tmux new-window -n "server" "npm run dev"
# Create in specific session
tmux new-window -t session_name -n "window_name"
# Horizontal split (left/right)
tmux split-window -h
# Vertical split (top/bottom)
tmux split-window -v
# Split with working directory
tmux split-window -h -c "/path/to/project"
# Split and run command
tmux split-window -h "tail -f logs/app.log"
Use send-keys to run commands in a specific pane:
# Send command to target pane (Enter executes it)
tmux send-keys -t target "npm run build" Enter
# Send without executing (omit Enter)
tmux send-keys -t target "npm run build"
# Send special keys
tmux send-keys -t target C-c # Ctrl+C
tmux send-keys -t target C-d # Ctrl+D
tmux send-keys -t target Escape
Use capture-pane to get console content:
# Capture visible content from target pane
tmux capture-pane -t target -p
# Capture with history (last 500 lines)
tmux capture-pane -t target -p -S -500
# Capture entire scrollback
tmux capture-pane -t target -p -S -
# Capture to file
tmux capture-pane -t target -p > output.txt
The -t flag specifies which session, window, or pane to target:
| Format | Description |
|---|---|
-t session | Target session by name |
-t session:window | Target window in session |
-t session:window.pane | Target specific pane |
-t :window | Window in current session |
-t :.pane | Pane in current window |
-t %N | Pane by ID (e.g., %0, %1) |
# List all panes with their IDs
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id}'
# List panes in current window
tmux list-panes -F '#{pane_index}: #{pane_id} #{pane_current_command}'
# Check if in tmux, then create window for long-running process
if [ -n "$TMUX" ]; then
tmux new-window -n "build" "npm run build"
fi
# Capture last 100 lines from pane 1
output=$(tmux capture-pane -t :.1 -p -S -100)
echo "$output"
# Send command to pane
tmux send-keys -t :.1 "npm test" Enter
# Wait a bit then capture output
sleep 5
tmux capture-pane -t :.1 -p -S -50
For iTerm2 with mouse selection (recommended):
Mouse selections in iTerm2 go to the macOS clipboard. Access via pbpaste:
# Get user's mouse selection from clipboard
selection=$(pbpaste)
echo "$selection"
For tmux copy-mode selections:
When using tmux copy-mode (prefix + [), selections go to tmux buffer:
# Get from tmux buffer
if selection=$(tmux show-buffer 2>/dev/null); then
echo "$selection"
else
echo "No selection in tmux buffer"
fi
# List all buffers
tmux list-buffers
# Load text into buffer programmatically
echo "some text" | tmux load-buffer -
This plugin provides commands for managing tmux panes:
| Command | Description |
|---|---|
/split-run <name> <cmd> | Split pane and run command with a name |
/capture-pane <name> [lines] | Capture output from a named pane |
/watch-pane <name> [secs] | Auto-inject pane output as context |
/unwatch-pane | Stop watching a pane |
/close-pane <name> | Close a pane by name |
/list-panes | List all panes with their names |
/fork-session [name] | Fork Claude session into new window |
Panes created with /split-run are automatically named. Reference them by name:
/split-run server npm run dev
/capture-pane server
/close-pane server
For advanced patterns like waiting for command completion and error handling, see references/advanced-scripting.md.
npx claudepluginhub koromiko/my_claudecode_marketplaceManages tmux sessions, windows, and panes for terminal multiplexing, persistent remote workflows surviving SSH disconnects, multi-pane layouts, and shell scripting automation.
Manages TMUX background processes: starts services in named panes of a 'claude-controlled' window, checks output, restarts, finds existing panes by title.