Home | Projects | Notes > Unix/Linux > Tmux Cheat Sheet
Start a new session
xxxxxxxxxx
11tmux
xxxxxxxxxx
11tmux new
xxxxxxxxxx
11tmux new-session
xxxxxxxxxx
11:new
Start a new session with a name
xxxxxxxxxx
11tmux new -s <session_name>
xxxxxxxxxx
11:new -s <session_name>
Kill/delete session
xxxxxxxxxx
11tmux kill-ses -t <session_name>
xxxxxxxxxx
11tmux kill-session -t <session_name>
Kill/delete all sessions but the current
xxxxxxxxxx
11tmux kill-session -a
Kill/delete all sessions but the current
xxxxxxxxxx
11tmux kill-session -a -t <session_name>
Rename session
Ctrl
+ b
$
Detach from session
Ctrl
+ b
d
Detach others on the session (Maximize window by detach other clients)
xxxxxxxxxx
11:attach -d
Show all sessions
xxxxxxxxxx
11tmux ls
xxxxxxxxxx
11tmux list-sessions
Ctrl
+ b
s
Attach to last session
xxxxxxxxxx
11tmux a
xxxxxxxxxx
11tmux at
xxxxxxxxxx
11tmux attach
xxxxxxxxxx
11tmux attach-session
Attach to a session with a name
xxxxxxxxxx
11tmux a -t <session_name>
xxxxxxxxxx
11tmux at -t <session_name>
xxxxxxxxxx
11tmux attach -t <session_name>
xxxxxxxxxx
11tmux attach-session -t <session_name>
Session and Window Preview
Ctrl
+ b
w
Move to previous session
Ctrl
+ b
(
Move to next session
Ctrl
+ b
)
Start a new session and window with names
xxxxxxxxxx
11tmux new -s <session_name> -n <window_name>
Create window
Ctrl
+ b
c
Rename current window
Ctrl
+ b
,
Close current window
Ctrl
+ b
&
List windows
Ctrl
+ b
w
Previous window
Ctrl
+ b
p
Next window
Ctrl
+ b
n
Switch/select window by number
Ctrl
+ b
0
...9
Toggle last active window
Ctrl
+ b
l
Reorder window, swap window number 2(src) and 1(dst)
xxxxxxxxxx
11:swap-window -s 2 -t 1
Move current window to the left by one position
xxxxxxxxxx
11:swap-window -t -1
Toggle last active pane
Ctrl
+ b
;
Split pane with horizontal layout
Ctrl
+ b
%
Split pane with vertical layout
Ctrl
+ b
"
Move the current pane left
Ctrl
+ b
{
Move the current pane right
Ctrl
+ b
}
Switch to pane to the direction
Ctrl
+ b
↑
Ctrl
+ b
↓
Ctrl
+ b
→
Ctrl
+ b
←
Toggle synchronize-panes(send command to all panes)
xxxxxxxxxx
11:setw synchronize-panes
Toggle between pane layouts
Ctrl
+ b
Spacebar
Switch to next pane
Ctrl
+ b
o
Show pane numbers
Ctrl
+ b
q
Switch/select pane by number
Ctrl
+ b
q
0
...9
Toggle pane zoom
Ctrl
+ b
z
Convert pane into a window
Ctrl
+ b
!
Resize current pane height(holding second key is optional)
Ctrl
+ b
↑
Ctrl
+ b
Ctrl
↑
Ctrl
+ b
↓
Ctrl
+ b
Ctrl
↓
Resize current pane width(holding second key is optional)
Ctrl
+ b
→
Ctrl
+ b
Ctrl
→
Ctrl
+ b
←
Ctrl
+ b
Ctrl
←
Equally balance split panes
Ctrl
+ b
, Alt
+ 1
(horizontal; equal width)
Ctrl
+ b
, Alt
+ 2
(vertical; equal height)
Close current pane
Ctrl
+ b
x
Use vi keys in buffer
xxxxxxxxxx
11setw -g mode-keys vi
Enter copy mode
Ctrl
+ b
[
Enter copy mode and scroll one page up
Ctrl
+ b
PgUp
Quit mode
q
Go to top line
g
Go to bottom line
G
Scroll up
↑
Scroll down
↓
Move cursor left
h
Move cursor down
j
Move cursor up
k
Move cursor right
l
Move cursor forward one word at a time
w
Move cursor backward one word at a time
b
Search forward
/
Search backward
?
Next keyword occurrence
n
Previous keyword occurrence
N
Start selection
Spacebar
Clear selection
Esc
Copy selection
Enter
Paste contents of buffer_0
Ctrl
+ b
]
Display buffer_0 contents
xxxxxxxxxx
11:show-buffer
Copy entire visible contents of pane to a buffer
xxxxxxxxxx
11:capture-pane
Show all buffers
xxxxxxxxxx
11:list-buffers
Show all buffers and paste selected
xxxxxxxxxx
11:choose-buffer
Save buffer contents to a file
xxxxxxxxxx
11:save-buffer <file>
Delete buffer_1
xxxxxxxxxx
11delete-buffer -b 1
Enter command mode
Ctrl
+ b
:
Set OPTION for all sessions
xxxxxxxxxx
11:set -g OPTION
Set OPTION for all windows
xxxxxxxxxx
11:setw -g OPTION
Enable mouse mode
xxxxxxxxxx
11:set mouse on
List key bindings(shortcuts)
xxxxxxxxxx
11tmux list-keys
xxxxxxxxxx
11:list-keys
Ctrl
+ b
?
Show every session, window, pane, etc...
xxxxxxxxxx
11tmux info