Commands Reference
FreshComplete tmux command reference for CLI and scripting.
Session Commands
| Command | Description |
|---|---|
tmux | Start new session |
tmux new | Start new session |
tmux new -s name | Start named session |
tmux new -s name -n window | Start with named window |
tmux new-session -A -s name | Attach or create |
tmux ls | List sessions |
tmux list-sessions | List sessions (full) |
tmux attach | Attach to last session |
tmux a | Attach (short) |
tmux attach -t name | Attach to named session |
tmux attach -dt name | Attach, detach others |
tmux kill-session -t name | Kill session |
tmux kill-session -a | Kill all but current |
tmux kill-session -a -t name | Kill all but named |
tmux rename-session -t old new | Rename session |
Window Commands
| Command | Description |
|---|---|
tmux new-window | Create window |
tmux new-window -n name | Create named window |
tmux list-windows | List windows |
tmux select-window -t :0 | Select window 0 |
tmux rename-window name | Rename current window |
tmux kill-window | Kill current window |
tmux kill-window -t :2 | Kill window 2 |
tmux swap-window -s 2 -t 1 | Swap windows 2 and 1 |
tmux swap-window -t -1 | Move window left |
tmux move-window -r | Renumber windows |
tmux move-window -s 0:1 -t 1: | Move window between sessions |
Pane Commands
| Command | Description |
|---|---|
tmux split-window -h | Split horizontal (left/right) |
tmux split-window -v | Split vertical (top/bottom) |
tmux split-window -h -c path | Split, start in path |
tmux select-pane -L/R/U/D | Select pane by direction |
tmux select-pane -t :.+ | Select next pane |
tmux resize-pane -L/R/U/D 5 | Resize by 5 cells |
tmux swap-pane -U | Swap with previous |
tmux swap-pane -D | Swap with next |
tmux kill-pane | Kill current pane |
tmux kill-pane -t 2 | Kill pane 2 |
tmux join-pane -s 2 -t 1 | Join window 2 to 1 |
tmux break-pane | Convert pane to window |
Copy Mode Commands
| Command | Description |
|---|---|
tmux copy-mode | Enter copy mode |
tmux show-buffer | Show buffer contents |
tmux list-buffers | List all buffers |
tmux choose-buffer | Interactive buffer select |
tmux paste-buffer | Paste buffer |
tmux save-buffer file.txt | Save buffer to file |
tmux load-buffer file.txt | Load file to buffer |
tmux delete-buffer | Delete most recent buffer |
tmux delete-buffer -b 2 | Delete buffer 2 |
tmux capture-pane | Capture pane content |
tmux capture-pane -p > out.txt | Capture to file |
Configuration Commands
| Command | Description |
|---|---|
tmux source-file ~/.tmux.conf | Reload config |
tmux show-options -g | Show global options |
tmux show-options -w | Show window options |
tmux set-option option value | Set option |
tmux setw option value | Set window option |
tmux list-keys | List key bindings |
tmux list-commands | List all commands |
New Command Flags (tmux 3.6)
| Command | Flag | Effect |
|---|---|---|
command-prompt | -l | Disable splitting input into multiple prompts |
display-popup | -k | Any key dismisses the popup once the command exits |
run-shell | -E | Forward stderr as well as stdout |
capture-pane | -M | Capture from the copy mode screen |
display-message | -C | Update 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 $SESSIONCreate 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 ideSend 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 keyTarget Syntax
tmux uses a target syntax for specifying sessions, windows, and panes:
session:window.pane| Target | Meaning |
|---|---|
mysession | Session named "mysession" |
mysession:2 | Window 2 in mysession |
mysession:editor | Window named "editor" |
mysession:2.1 | Pane 1 in window 2 |
:2 | Window 2 in current session |
:.1 | Pane 1 in current window |
Environment Variables
| Variable | Description |
|---|---|
TMUX | Set when inside tmux |
TMUX_PANE | Current pane ID |
bash
# Check if in tmux
if [ -n "$TMUX" ]; then
echo "Inside tmux"
fi