Skip to content

Commands Reference

Fresh

Complete tmux command reference for CLI and scripting.

Session Commands

CommandDescription
tmuxStart new session
tmux newStart new session
tmux new -s nameStart named session
tmux new -s name -n windowStart with named window
tmux new-session -A -s nameAttach or create
tmux lsList sessions
tmux list-sessionsList sessions (full)
tmux attachAttach to last session
tmux aAttach (short)
tmux attach -t nameAttach to named session
tmux attach -dt nameAttach, detach others
tmux kill-session -t nameKill session
tmux kill-session -aKill all but current
tmux kill-session -a -t nameKill all but named
tmux rename-session -t old newRename session

Window Commands

CommandDescription
tmux new-windowCreate window
tmux new-window -n nameCreate named window
tmux list-windowsList windows
tmux select-window -t :0Select window 0
tmux rename-window nameRename current window
tmux kill-windowKill current window
tmux kill-window -t :2Kill window 2
tmux swap-window -s 2 -t 1Swap windows 2 and 1
tmux swap-window -t -1Move window left
tmux move-window -rRenumber windows
tmux move-window -s 0:1 -t 1:Move window between sessions

Pane Commands

CommandDescription
tmux split-window -hSplit horizontal (left/right)
tmux split-window -vSplit vertical (top/bottom)
tmux split-window -h -c pathSplit, start in path
tmux select-pane -L/R/U/DSelect pane by direction
tmux select-pane -t :.+Select next pane
tmux resize-pane -L/R/U/D 5Resize by 5 cells
tmux swap-pane -USwap with previous
tmux swap-pane -DSwap with next
tmux kill-paneKill current pane
tmux kill-pane -t 2Kill pane 2
tmux join-pane -s 2 -t 1Join window 2 to 1
tmux break-paneConvert pane to window

Copy Mode Commands

CommandDescription
tmux copy-modeEnter copy mode
tmux show-bufferShow buffer contents
tmux list-buffersList all buffers
tmux choose-bufferInteractive buffer select
tmux paste-bufferPaste buffer
tmux save-buffer file.txtSave buffer to file
tmux load-buffer file.txtLoad file to buffer
tmux delete-bufferDelete most recent buffer
tmux delete-buffer -b 2Delete buffer 2
tmux capture-paneCapture pane content
tmux capture-pane -p > out.txtCapture to file

Configuration Commands

CommandDescription
tmux source-file ~/.tmux.confReload config
tmux show-options -gShow global options
tmux show-options -wShow window options
tmux set-option option valueSet option
tmux setw option valueSet window option
tmux list-keysList key bindings
tmux list-commandsList all commands

New Command Flags (tmux 3.6)

CommandFlagEffect
command-prompt-lDisable splitting input into multiple prompts
display-popup-kAny key dismisses the popup once the command exits
run-shell-EForward stderr as well as stdout
capture-pane-MCapture from the copy mode screen
display-message-CUpdate the pane while the message is displayed
bash
# Dismiss a popup with any key after the command finishes
tmux display-popup -k -E "htop"

# Run a script and surface its stderr too
tmux run-shell -E "./deploy.sh"

# Single-line command prompt (no splitting)
tmux command-prompt -l -p "search:" "copy-mode -e; send -X search-forward '%%'"

Scripting Examples

Create Development Environment

bash
#!/bin/bash
SESSION="dev"
PROJECT_PATH="$HOME/project"

# Create session (detached)
tmux new-session -d -s $SESSION -c $PROJECT_PATH

# Create windows
tmux rename-window -t $SESSION:0 'editor'
tmux new-window -t $SESSION -n 'server'
tmux new-window -t $SESSION -n 'tests'

# Send commands
tmux send-keys -t $SESSION:editor 'vim .' C-m
tmux send-keys -t $SESSION:server 'npm run dev' C-m
tmux send-keys -t $SESSION:tests 'npm test -- --watch' C-m

# Select first window and attach
tmux select-window -t $SESSION:editor
tmux attach -t $SESSION

Create Pane Layout

bash
#!/bin/bash
# Create IDE-like layout

tmux new-session -d -s ide

# Main editor pane (already exists)
# Split right for terminal
tmux split-window -h -p 30

# Split bottom-right for output
tmux split-window -v -p 50

# Select editor pane
tmux select-pane -t 0

tmux attach -t ide

Send Commands to Running Session

bash
# Send command to specific window
tmux send-keys -t mysession:server 'npm restart' C-m

# Send command to specific pane
tmux send-keys -t mysession:0.1 'tail -f logs' C-m

# C-m is Enter key

Target Syntax

tmux uses a target syntax for specifying sessions, windows, and panes:

session:window.pane
TargetMeaning
mysessionSession named "mysession"
mysession:2Window 2 in mysession
mysession:editorWindow named "editor"
mysession:2.1Pane 1 in window 2
:2Window 2 in current session
:.1Pane 1 in current window

Environment Variables

VariableDescription
TMUXSet when inside tmux
TMUX_PANECurrent pane ID
bash
# Check if in tmux
if [ -n "$TMUX" ]; then
    echo "Inside tmux"
fi

See Also

Generated with AI-powered SOP Generator