tmux Cheat Sheet
The default prefix key is Ctrl+b (shown as C-b below).
Sessions
Section titled “Sessions”Command Line
Section titled “Command Line”| Command | Description |
|---|---|
tmux | Start new session |
tmux new -s name | Start named session |
tmux ls | List sessions |
tmux attach | Attach to last session |
tmux attach -t name | Attach to named session |
tmux kill-session -t name | Kill session |
tmux kill-server | Kill all sessions |
Inside tmux
Section titled “Inside tmux”| Keybinding | Description |
|---|---|
C-b d | Detach from session |
C-b $ | Rename session |
C-b s | List/switch sessions |
C-b ( | Previous session |
C-b ) | Next session |
C-b L | Last (previous) session |
Windows (Tabs)
Section titled “Windows (Tabs)”| Keybinding | Description |
|---|---|
C-b c | Create new window |
C-b , | Rename current window |
C-b & | Close current window |
C-b w | List windows (interactive) |
C-b n | Next window |
C-b p | Previous window |
C-b l | Last (toggle) window |
C-b 0-9 | Switch to window 0-9 |
C-b ' | Switch to window by number |
C-b . | Move window to another index |
C-b f | Find window by name |
Panes (Splits)
Section titled “Panes (Splits)”Creating Panes
Section titled “Creating Panes”| Keybinding | Description |
|---|---|
C-b % | Split horizontally (left/right) |
C-b " | Split vertically (top/bottom) |
Navigating Panes
Section titled “Navigating Panes”| Keybinding | Description |
|---|---|
C-b ←↑↓→ | Move to pane in direction |
C-b o | Cycle through panes |
C-b ; | Toggle last active pane |
C-b q | Show pane numbers |
C-b q 0-9 | Switch to pane by number |
Resizing Panes
Section titled “Resizing Panes”| Keybinding | Description |
|---|---|
C-b C-←↑↓→ | Resize pane (small increment) |
C-b M-←↑↓→ | Resize pane (large increment) |
C-b z | Toggle pane zoom (fullscreen) |
C-b ! | Convert pane to window |
Pane Layouts
Section titled “Pane Layouts”| Keybinding | Description |
|---|---|
C-b Space | Cycle through layouts |
C-b M-1 | Even horizontal |
C-b M-2 | Even vertical |
C-b M-3 | Main horizontal |
C-b M-4 | Main vertical |
C-b M-5 | Tiled |
Other Pane Operations
Section titled “Other Pane Operations”| Keybinding | Description |
|---|---|
C-b x | Kill pane (with confirmation) |
C-b { | Swap pane with previous |
C-b } | Swap pane with next |
C-b C-o | Rotate panes forward |
C-b M-o | Rotate panes backward |
Copy Mode
Section titled “Copy Mode”| Keybinding | Description |
|---|---|
C-b [ | Enter copy mode |
C-b ] | Paste buffer |
C-b = | Choose buffer to paste |
C-b # | List buffers |
q | Exit copy mode |
In Copy Mode (vi keys)
Section titled “In Copy Mode (vi keys)”| Keybinding | Description |
|---|---|
Space | Start selection |
Enter | Copy selection and exit |
Escape | Clear selection |
v | Begin selection (if vi-copy) |
y | Yank selection (if vi-copy) |
/ | Search forward |
? | Search backward |
n | Next search result |
N | Previous search result |
g | Go to top |
G | Go to bottom |
h j k l | Move cursor |
w b | Word forward/backward |
0 $ | Start/end of line |
C-u C-d | Half page up/down |
C-b C-f | Full page up/down |
Command Mode
Section titled “Command Mode”| Keybinding | Description |
|---|---|
C-b : | Enter command mode |
Useful Commands
Section titled “Useful Commands”# In command mode (C-b :)source-file ~/.tmux.conf # Reload configlist-keys # List all keybindingslist-commands # List all commandsdisplay-message "text" # Show messageset -g option value # Set global optionsetw -g option value # Set window option
# Pane operationsswap-pane -s 0 -t 1 # Swap panesjoin-pane -s 1 -t 0 # Join pane from window 1break-pane # Move pane to new window
# Sync panes (type in all panes simultaneously)setw synchronize-panes onsetw synchronize-panes offConfiguration (~/.tmux.conf)
Section titled “Configuration (~/.tmux.conf)”# Change prefix to C-aunbind C-bset -g prefix C-abind C-a send-prefix
# Enable mouseset -g mouse on
# Start windows and panes at 1set -g base-index 1setw -g pane-base-index 1
# Vi modesetw -g mode-keys vi
# Better splits (| and -)bind | split-window -h -c "#{pane_current_path}"bind - split-window -v -c "#{pane_current_path}"
# Vim-style pane navigationbind h select-pane -Lbind j select-pane -Dbind k select-pane -Ubind l select-pane -R
# Resize panes with vim keysbind -r H resize-pane -L 5bind -r J resize-pane -D 5bind -r K resize-pane -U 5bind -r L resize-pane -R 5
# Quick reloadbind r source-file ~/.tmux.conf \; display "Reloaded!"
# Don't rename windows automaticallyset -g allow-rename off
# Increase history limitset -g history-limit 50000
# Faster escape time (for vim)set -sg escape-time 0
# 256 color supportset -g default-terminal "screen-256color"set -ga terminal-overrides ",*256col*:Tc"
# Status barset -g status-position topset -g status-style 'bg=#333333 fg=#ffffff'set -g status-left '#[fg=green]#S 'set -g status-right '%H:%M %d-%b'
# Active windowsetw -g window-status-current-style 'fg=black bg=white'
# Pane bordersset -g pane-border-style 'fg=#444444'set -g pane-active-border-style 'fg=#00ff00'Scripting
Section titled “Scripting”Create session with windows and panes
Section titled “Create session with windows and panes”#!/bin/bashSESSION="dev"
# Create session with first windowtmux new-session -d -s $SESSION -n "editor"
# Create additional windowstmux new-window -t $SESSION -n "server"tmux new-window -t $SESSION -n "logs"
# Split the editor windowtmux select-window -t $SESSION:editortmux split-window -htmux split-window -v
# Run commands in panestmux send-keys -t $SESSION:editor.0 'nvim' C-mtmux send-keys -t $SESSION:server 'npm run dev' C-mtmux send-keys -t $SESSION:logs 'tail -f /var/log/app.log' C-m
# Attach to sessiontmux attach -t $SESSIONTargeting windows and panes
Section titled “Targeting windows and panes”# Format: session:window.panetmux send-keys -t mysession:0.1 'ls' C-mtmux select-window -t mysession:editortmux select-pane -t mysession:0.2Useful Tricks
Section titled “Useful Tricks”Send command to all panes
Section titled “Send command to all panes”# Toggle syncC-b : setw synchronize-panes on# Type command (appears in all panes)# Toggle offC-b : setw synchronize-panes offSave pane output to file
Section titled “Save pane output to file”C-b : capture-pane -S -3000C-b : save-buffer ~/tmux.logPipe pane output
Section titled “Pipe pane output”C-b : pipe-pane -o 'cat >> ~/output.log'Clear pane history
Section titled “Clear pane history”C-b : clear-historyShow all keybindings
Section titled “Show all keybindings”tmux list-keystmux list-keys | grep split # FilterQuick Reference
Section titled “Quick Reference”| Task | Command |
|---|---|
| New session | tmux new -s name |
| Attach | tmux attach -t name |
| Detach | C-b d |
| New window | C-b c |
| Split horizontal | C-b % |
| Split vertical | C-b " |
| Navigate panes | C-b arrows |
| Zoom pane | C-b z |
| Kill pane | C-b x |
| Copy mode | C-b [ |
| Paste | C-b ] |
| Command mode | C-b : |
| List sessions | C-b s |
| List windows | C-b w |
See Also
Section titled “See Also”- tmux Lesson Plan — 8 lessons from basics to scripting
- Terminal Emulators — iTerm2 vs Ghostty, tmux -CC integration
- Agent Orchestration — tmux for multi-agent sessions
- Shell — Scripting patterns for tmux automation
- Neovim Commands (LazyVim)
- CLI-First