tmux Scripting, Formats, and Automation

tmux commands for listing state, using format strings, conditional logic, send-keys automation, and repeatable workspace bootstrapping.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Listing and formats
List windows with a custom format
tmux list-windows -F "#{session_name}:#{window_index}:#{window_name}:#{window_active}"

# Print a compact machine-friendly window summary.

List panes with path and command
tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index} #{pane_current_path} #{pane_current_command}"

# Inspect pane metadata.

Print a format string
tmux display-message -p "#{client_termname} #{session_name} #{pane_id}"

# Evaluate a format without changing the UI.

Conditionally run a command
tmux if-shell "test -f package.json" "display-message "node project""

# Branch based on shell command success.

Run an external shell command
tmux run-shell "~/.tmux/scripts/session-bootstrap.sh"

# Execute shell logic from tmux.

## Repeatable workspaces
Build a session in the background
tmux new-session -d -s api -n editor

# Create a detached session before laying out windows.

Send a command into a pane
tmux send-keys -t api:editor "npm run dev" C-m

# Programmatically run startup commands.

Focus a specific window
tmux select-window -t api:editor

# Choose the window users should see first.

Attach after setup
tmux attach-session -t api

# Open the session after all windows and panes are ready.

Recommended next

No recommendations yet.