Table of Contents

Tmux Command mode

Command mode lets you type raw tmux commands to control sessions, windows, and panes. Enter command mode with Ctrl+B :, type a command, and press Enter.

Ctrl+B :            enter command mode

Common commands:

# Window management
new-window -n name              create window named "name"
kill-window                     kill current window
rename-window new-name          rename current window
 
# Pane management
split-window -v                 split vertically (top/bottom)
split-window -h                 split horizontally (left/right)
kill-pane                       kill current pane
send-keys -t window "cmd" Enter  send command to window
 
# Session management
new-session -s name             create named session
kill-session -t name            kill session
rename-session -t old new       rename session
 
# General
list-sessions                   list all sessions
list-windows -t session         list windows in session
list-panes -t session:window    list panes in window
set-option -g option value      set global option
set-window-option -g option value  set window option

Most key bindings are shortcuts for commands. For example, Ctrl+B c is equivalent to Ctrl+B :new-window Enter. Some commands are easier to type than to remember the keybinding.

View all available commands:

$ tmux list-commands

Common patterns in scripts:

# Send a command to a window and execute it
tmux send-keys -t session:window "npm start" Enter
 
# Create a new window in an existing session
tmux new-window -t session -n build -c ~/build
 
# Set a variable for the current session
tmux set-option -t session option value
 
# Get the value of an option
tmux show-option -t session option

Command mode is powerful for automation and scripting. You can run multiple commands in sequence to set up complex layouts programmatically.