Tmux Cheat Sheet
A complete reference of Tmux commands for terminal multiplexing. Find session, window, and pane management commands with examples and keyboard shortcuts.
tmux new-session
SessionCreate a new tmux session
Syntax:
tmux new-session [-d] [-s session-name] [command]
Examples:
tmux new-session
Create a new session with default nametmux new-session -s mysession
Create session named 'mysession'tmux new-session -d -s background
Create detached session named 'background'tmux new -s work
Shorthand for creating session 'work'Notes:
Use -d flag to create detached session (runs in background)
tmux attach-session
SessionAttach to an existing tmux session
Syntax:
tmux attach-session [-t session-name]
Examples:
tmux attach-session
Attach to most recent sessiontmux attach-session -t mysession
Attach to session named 'mysession'tmux attach -t work
Shorthand for attaching to 'work' sessiontmux a -t 0
Attach to session with ID 0Notes:
If no session name specified, attaches to the most recently used session
tmux list-sessions
SessionList all tmux sessions
Syntax:
tmux list-sessions
Examples:
tmux list-sessions
Show all active sessionstmux ls
Shorthand for listing sessionstmux list-sessions -F '#{session_name}: #{session_windows} windows'
Custom format showing session name and window countNotes:
Shows session name, number of windows, creation time, and attached status
tmux kill-session
SessionTerminate a tmux session
Syntax:
tmux kill-session [-t session-name]
Examples:
tmux kill-session -t mysession
Kill session named 'mysession'tmux kill-session -t 0
Kill session with ID 0tmux kill-server
Kill all sessions and the tmux serverNotes:
Killing a session will terminate all windows and panes within it
Prefix + d
SessionDetach from current session
Syntax:
Ctrl-b d (default prefix)
Examples:
Ctrl-b d
Detach from current sessionCtrl-b D
Detach and choose which client to detachNotes:
Session continues running in background after detaching
Prefix + c
WindowCreate a new window
Syntax:
Ctrl-b c (default prefix)
Examples:
Ctrl-b c
Create new window with next available numbertmux new-window
Create new window from command linetmux new-window -n 'logs'
Create new window named 'logs'Notes:
New window starts at current working directory of the session
Prefix + w
WindowList all windows in current session
Syntax:
Ctrl-b w (default prefix)
Examples:
Ctrl-b w
Show window list with previewtmux list-windows
List windows from command linetmux lsw
Shorthand for listing windowsNotes:
Use arrow keys to navigate and Enter to select a window
Prefix + [0-9]
WindowSwitch to window by number
Syntax:
Ctrl-b [number] (default prefix)
Examples:
Ctrl-b 0
Switch to window 0Ctrl-b 1
Switch to window 1Ctrl-b 9
Switch to window 9Ctrl-b '
Switch to window by name (prompt)Notes:
Windows are numbered starting from 0
Prefix + n
WindowMove to next window
Syntax:
Ctrl-b n (default prefix)
Examples:
Ctrl-b n
Go to next windowCtrl-b p
Go to previous windowCtrl-b l
Go to last used windowNotes:
Cycles through windows in order
Prefix + ,
WindowRename current window
Syntax:
Ctrl-b , (default prefix)
Examples:
Ctrl-b ,
Rename current window (interactive)tmux rename-window newname
Rename window from command lineNotes:
Window names appear in the status bar
Prefix + &
WindowClose current window
Syntax:
Ctrl-b & (default prefix)
Examples:
Ctrl-b &
Close current window (with confirmation)exit
Close window by exiting shelltmux kill-window -t 1
Kill window 1 from command lineNotes:
Closing the last window in a session will terminate the session
Prefix + %
PaneSplit pane horizontally (side by side)
Syntax:
Ctrl-b % (default prefix)
Examples:
Ctrl-b %
Split current pane horizontallytmux split-window -h
Split horizontally from command linetmux split-window -h -c '#{pane_current_path}'
Split horizontally in same directoryNotes:
Creates a new pane to the right of the current pane
Prefix + "
PaneSplit pane vertically (top and bottom)
Syntax:
Ctrl-b " (default prefix)
Examples:
Ctrl-b "
Split current pane verticallytmux split-window -v
Split vertically from command linetmux split-window -v -c '#{pane_current_path}'
Split vertically in same directoryNotes:
Creates a new pane below the current pane
Prefix + arrow keys
PaneNavigate between panes
Syntax:
Ctrl-b [←→↑↓] (default prefix)
Examples:
Ctrl-b ←
Move to pane on the leftCtrl-b →
Move to pane on the rightCtrl-b ↑
Move to pane aboveCtrl-b ↓
Move to pane belowCtrl-b o
Cycle through panesNotes:
Use arrow keys or 'o' to move between panes
Prefix + Ctrl + arrow keys
PaneResize panes
Syntax:
Ctrl-b Ctrl-[←→↑↓] (default prefix)
Examples:
Ctrl-b Ctrl-←
Resize pane leftCtrl-b Ctrl-→
Resize pane rightCtrl-b Ctrl-↑
Resize pane upCtrl-b Ctrl-↓
Resize pane downtmux resize-pane -L 5
Resize current pane 5 cells leftNotes:
Hold Ctrl and use arrow keys to resize incrementally
Prefix + x
PaneClose current pane
Syntax:
Ctrl-b x (default prefix)
Examples:
Ctrl-b x
Close current pane (with confirmation)exit
Close pane by exiting shelltmux kill-pane -t 1
Kill pane 1 from command lineNotes:
Closing the last pane in a window will close the window
Prefix + z
PaneToggle pane zoom (fullscreen)
Syntax:
Ctrl-b z (default prefix)
Examples:
Ctrl-b z
Toggle fullscreen for current paneNotes:
Press again to return to multi-pane view
Prefix + spacebar
PaneCycle through pane layouts
Syntax:
Ctrl-b Space (default prefix)
Examples:
Ctrl-b Space
Cycle through predefined layoutstmux select-layout even-horizontal
Arrange panes in even horizontal layouttmux select-layout even-vertical
Arrange panes in even vertical layouttmux select-layout main-horizontal
Main pane on top, others belowtmux select-layout main-vertical
Main pane on left, others rightNotes:
Available layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled
Prefix + [
Copy ModeEnter copy mode for scrolling and text selection
Syntax:
Ctrl-b [ (default prefix)
Examples:
Ctrl-b [
Enter copy modeq
Exit copy modeg
Go to top of bufferG
Go to bottom of buffer/
Search forward?
Search backwardNotes:
Use vi or emacs key bindings to navigate (set in tmux.conf)
Space / v
Copy ModeStart text selection in copy mode
Syntax:
Space (or v for vi mode)
Examples:
Space
Start selection (default mode)v
Start selection (vi mode)V
Start line selection (vi mode)Enter
Copy selection and exit copy modeNotes:
Selection behavior depends on your key binding mode (vi or emacs)
Prefix + ]
Copy ModePaste most recent copied text
Syntax:
Ctrl-b ] (default prefix)
Examples:
Ctrl-b ]
Paste last copied texttmux paste-buffer
Paste from command linetmux list-buffers
List all copy bufferstmux paste-buffer -b 0
Paste from specific bufferNotes:
Tmux maintains multiple copy buffers with numbered history
Prefix + :
ConfigurationEnter command mode
Syntax:
Ctrl-b : (default prefix)
Examples:
Ctrl-b :
Open command prompt:source-file ~/.tmux.conf
Reload configuration file:set -g mouse on
Enable mouse support:set -g status-bg red
Change status bar background to redNotes:
Command mode allows running any tmux command interactively
tmux show-options
ConfigurationDisplay tmux options and their values
Syntax:
tmux show-options [-g] [-s] [-w]
Examples:
tmux show-options -g
Show global optionstmux show-options -w
Show window optionstmux show-options -s
Show server optionstmux show-options -g status
Show specific option valueNotes:
Use -g for global, -w for window, -s for server options
tmux set-option
ConfigurationSet tmux options
Syntax:
tmux set-option [-g] [-w] option value
Examples:
tmux set-option -g prefix C-a
Change prefix key to Ctrl-atmux set-option -g mouse on
Enable mouse supporttmux set-option -g status-position top
Move status bar to toptmux set-option -w automatic-rename off
Disable automatic window renamingNotes:
Use -g for global options, -w for window options
Prefix + ?
InformationShow key bindings help
Syntax:
Ctrl-b ? (default prefix)
Examples:
Ctrl-b ?
Display all key bindingsCtrl-b t
Show current timetmux info
Show session informationtmux list-keys
List all key bindings from command lineNotes:
Press q to exit the help screen
Prefix + t
InformationDisplay a clock in current pane
Syntax:
Ctrl-b t (default prefix)
Examples:
Ctrl-b t
Show digital clocktmux clock-mode
Enter clock mode from command lineNotes:
Press any key to exit clock mode
tmux capture-pane
AdvancedCapture pane contents to a buffer
Syntax:
tmux capture-pane [-p] [-t target-pane]
Examples:
tmux capture-pane -p
Capture and print current pane contentstmux capture-pane -t 1
Capture pane 1 contentstmux capture-pane -S -1000
Capture with scrollback historytmux capture-pane -p > output.txt
Save pane contents to fileNotes:
Useful for saving terminal output or debugging
tmux send-keys
AdvancedSend keystrokes to a pane
Syntax:
tmux send-keys [-t target] keys
Examples:
tmux send-keys -t 1 'ls -la' Enter
Send command to pane 1tmux send-keys 'echo hello' C-m
Send command with Enter keytmux send-keys -t mysession:1.0 'top' Enter
Send to specific session:window.paneNotes:
Useful for automation and sending commands to background sessions
tmux pipe-pane
AdvancedPipe pane output to a command or file
Syntax:
tmux pipe-pane [-o] [-t target] command
Examples:
tmux pipe-pane -o 'cat >> ~/session.log'
Log all output to filetmux pipe-pane
Stop piping (toggle off)tmux pipe-pane -t 1 'grep ERROR'
Filter pane 1 output for errorsNotes:
Use -o flag to only capture visible output, not scrollback
tmux join-pane
AdvancedMove a pane from one window to another
Syntax:
tmux join-pane [-s src-pane] [-t dst-window]
Examples:
tmux join-pane -s 1 -t 0
Move pane 1 to window 0tmux join-pane -h -s 1
Join pane 1 horizontally to current windowtmux join-pane -v -s mysession:1.0
Join specific pane verticallyNotes:
Use -h for horizontal join, -v for vertical join
Prefix + !
AdvancedBreak current pane into a new window
Syntax:
Ctrl-b ! (default prefix)
Examples:
Ctrl-b !
Move current pane to new windowtmux break-pane
Break pane from command linetmux break-pane -t 1
Break specific pane to new windowNotes:
Useful for promoting a pane to its own window
tmux has-session
ScriptingCheck if a session exists
Syntax:
tmux has-session [-t session-name]
Examples:
tmux has-session -t mysession
Check if 'mysession' existstmux has-session -t mysession && echo 'exists' || echo 'not found'
Conditional check in scriptNotes:
Returns exit code 0 if session exists, 1 if not - useful in scripts
tmux run-shell
ScriptingRun shell command in background
Syntax:
tmux run-shell [-d] command
Examples:
tmux run-shell 'echo hello'
Run command and show output in tmuxtmux run-shell -d 'sleep 5 && tmux display-message "Done"'
Run command in backgroundNotes:
Useful for running commands from within tmux configuration
tmux display-message
ScriptingDisplay a message in the status line
Syntax:
tmux display-message [-p] [message]
Examples:
tmux display-message 'Hello World'
Show message in status linetmux display-message -p '#{session_name}'
Print current session nametmux display-message 'Current time: %H:%M'
Show formatted timeNotes:
Use -p flag to print to stdout instead of status line
Pro Tmux Tips
Essential Workflow
tmux new -s work
- Start a named sessionCtrl-b c
- Create new windowCtrl-b %
- Split pane horizontallyCtrl-b "
- Split pane verticallyCtrl-b d
- Detach from sessiontmux attach -t work
- Reattach to session
Best Practices
- Use named sessions for different projects
- Create a custom
~/.tmux.conf
file - Learn the default prefix key (Ctrl-b)
- Use
tmux ls
to see active sessions - Enable mouse mode for easier pane resizing
- Use copy mode to scroll and select text
Quick Configuration
Add these to your ~/.tmux.conf
for a better experience:
# Enable mouse support set -g mouse on # Start windows and panes at 1, not 0 set -g base-index 1 set -g pane-base-index 1 # Reload config with Prefix + r bind r source-file ~/.tmux.conf \; display "Config reloaded!"