Skip to main content

tmux Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for tmux sessions, windows, panes, and common commands

tmux is a terminal multiplexer that lets you manage multiple sessions, windows, and panes in a single terminal. This cheatsheet covers the most common commands and key bindings.

Start and Exit

CommandDescription
tmuxStart a new session
tmux new -s workStart session named work
tmux lsList sessions
tmux kill-session -t workKill session work
tmux kill-serverStop tmux server
exitExit current shell (pane)

Attach and Switch

Key / CommandDescription
tmux attachAttach to the most recent session from the shell
tmux attach -t workAttach to session work from the shell
Ctrl+b sChoose a session from the session list
Ctrl+b (Switch to the previous session
Ctrl+b )Switch to the next session
Ctrl+b dDetach from the current session

Prefix Key

Default prefix is Ctrl+b.

KeyDescription
Ctrl+bEnter tmux command mode
Ctrl+b ?Show key bindings
Ctrl+b :Open command prompt

Windows

Key / CommandDescription
Ctrl+b cCreate new window
Ctrl+b ,Rename current window
Ctrl+b &Kill current window
Ctrl+b nNext window
Ctrl+b pPrevious window
Ctrl+b 0-9Switch to window by number

Panes

KeyDescription
Ctrl+b %Split pane vertically
Ctrl+b "Split pane horizontally
Ctrl+b xKill current pane
Ctrl+b oCycle panes
Ctrl+b qShow pane numbers
Ctrl+b ;Toggle last active pane
Ctrl+b zZoom/unzoom pane

Pane Navigation

KeyDescription
Ctrl+b ←/→/↑/↓Move between panes
Ctrl+b Ctrl+←/→/↑/↓Resize the current pane
Ctrl+b Alt+1Select the even-horizontal layout
Ctrl+b Alt+2Select the even-vertical layout
Ctrl+b Alt+5Select the tiled layout

Copy Mode

KeyDescription
Ctrl+b [Enter copy mode
qExit copy mode
SpaceStart selection
EnterCopy selection
Ctrl+b ]Paste buffer

Common Commands

CommandDescription
tmux rename-session -t work newnameRename session
tmux new -s work -dStart detached session
tmux rename-window -t 1 editorRename window 1
tmux kill-pane -t 2Kill pane 2
tmux list-keysList all key bindings

Configuration

File / CommandDescription
~/.tmux.confUser config file
tmux source-file ~/.tmux.confReload config
set -g mouse onEnable mouse mode
setw -g mode-keys viUse vi keys in copy mode

Useful Patterns

PatternDescription
tmux new -s work -d \; new-window -t work:2 \; attach -t workCreate session, window, attach
tmux ls | catSimple list for scripts
tmux has-session -t workCheck if session exists