Skill

tmux

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.

From tmux-session-tools
Install
1
Run in your terminal
$
npx claudepluginhub koromiko/my_claudecode_marketplace
Tool Access

This skill uses the workspace's default tool permissions.

Supporting Assets
View in Repository
references/advanced-scripting.md
Skill Content

Tmux Operations for Claude Code

Reference for tmux commands to manage multiple terminals, run background processes, and capture output from other panes.

Detecting Tmux Environment

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

Creating New Windows and Panes

New Window

# 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"

Split Pane

# 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"

Executing Commands in Other Panes

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

Capturing Output from Panes

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

Target Specification

The -t flag specifies which session, window, or pane to target:

FormatDescription
-t sessionTarget session by name
-t session:windowTarget window in session
-t session:window.paneTarget specific pane
-t :windowWindow in current session
-t :.panePane in current window
-t %NPane by ID (e.g., %0, %1)

Finding Pane IDs

# 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}'

Common Patterns

Run Background Process in New Window

# Check if in tmux, then create window for long-running process
if [ -n "$TMUX" ]; then
    tmux new-window -n "build" "npm run build"
fi

Get Output from Another Pane

# Capture last 100 lines from pane 1
output=$(tmux capture-pane -t :.1 -p -S -100)
echo "$output"

Send Command and Wait for Completion

# 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

Get User Selection from Another Pane

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 -

Plugin Commands

This plugin provides commands for managing tmux panes:

CommandDescription
/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-paneStop watching a pane
/close-pane <name>Close a pane by name
/list-panesList all panes with their names
/fork-session [name]Fork Claude session into new window

Named Panes

Panes created with /split-run are automatically named. Reference them by name:

/split-run server npm run dev
/capture-pane server
/close-pane server

Additional Resources

For advanced patterns like waiting for command completion and error handling, see references/advanced-scripting.md.

Similar Skills
cache-components

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

138.5k
Stats
Parent Repo Stars0
Parent Repo Forks0
Last CommitJan 28, 2026