A tmux cheat sheet

I just started using tmux last week, and created a cheat sheet to help me remember the basic tmux commands, and I thought I'd share that here.

The cheat sheet has a few things that are specific to my configuration file, so to begin with, here is my ~/.tmux.conf file:

# use | and - to split the windows
bind-key | split-window -h
bind-key - split-window -v

# make the first window number start at 1
set -g base-index 1

# from http://endot.org/2011/12/06/my-tmux-configuration/
# keybindings to make resizing easier
bind -r C-h resize-pane -L
bind -r C-j resize-pane -D
bind -r C-k resize-pane -U
bind -r C-l resize-pane -R

Here's an HTML version of the cheat sheet:

new window ^b c
close window ^d or ^b x
kill window ^b &
next window ^b n
previous window ^b p
rename window ^b
list all windows ^b w
move to window number ^b [number]
   
split window vertically ^b %
split window horizontally ^b “
next pane ^b o
previous pane ^b ;
show pane numbers ^b q
move pane left ^b {
move pane right ^b {
swap pane locations ^b ^o
   
resize pane down ^b ^j or ^b : resize-pane XX
resize pane up ^b ^k or ^b : resize-pane -U XX
resize pane left ^b ^h or ^b : resize-pane -L
resize pane right ^b ^j or ^b : resize-pane -R
   
re-attach a detached session tmux attach
list sessions ^b s or tmux ls
   
start scroll mode ^b [
exit scroll mode q

My tmux PDF cheat sheet

Here's a PDF version of the tmux cheat sheet you can download:

Also, because I'm a tmux newbie, I may have missed some obvious, useful commands. If you think a command should be added, leave a note in the Comments section below, and I'll see what I can do. (I can make a web page as long as I need to, but I'd like to keep the PDF to one page.)

Default command key bindings

In case I missed any good commands in the list above, I just found this list of default command key bindings in the tmux man page. I rearranged the order of the commands to organize them a bit:

C-b         Send the prefix key (C-b) through to the application.

f           Prompt to search for text in open windows.
#           List all paste buffers.
-           Delete the most recently copied buffer of text.
=           Choose which buffer to paste interactively from a list.

c           Create a new window.
,           Rename the current window.
'           Prompt for a window index to select.
.           Prompt for an index to move the current window.
0 to 9      Select windows 0 to 9.
&           Kill the current window.
i           Display some information about the current window.
l           Move to the previously selected window.
n           Change to the next window.
p           Change to the previous window.
w           Choose the current window interactively.
M-n         Move to the next window with a bell or activity marker.
M-p         Move to the previous window with a bell or activity marker.

;           Move to the previously active pane.
o           Select the next pane in the current window.
x           Kill the current pane.
{           Swap the current pane with the previous pane.
}           Swap the current pane with the next pane.
!           Break the current pane out of the window.
"           Split the current pane into two, top and bottom.
%           Split the current pane into two, left and right.

C-o         Rotate the panes in the current window forwards.
            Change to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5  Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
C-Up, C-Down
C-Left, C-Right
            Resize the current pane in steps of one cell.
M-Up, M-Down
M-Left, M-Right
            Resize the current pane in steps of five cells.
q           Briefly display pane indexes.
M-o         Rotate the panes in the current window backwards.

:           Enter the tmux command prompt.
?           List all key bindings.

[           Enter copy mode to copy text or view the history.
Page Up     Enter copy mode and scroll one page up.
Up, Down
Left, Right
]           Paste the most recently copied buffer of text.

C-z         Suspend the tmux client.
$           Rename the current session.
s           Select a new session for the attached client interactively.
L           Switch the attached client back to the last session.
d           Detach the current client.
D           Choose a client to detach.
r           Force redraw of the attached client.

t           Show the time.
~           Show previous messages from tmux, if any.

If you're new to tmux, I hope this is helpful.