This is the minimum you should memorize to feel at home on any server your SSH into. There are many cheatsheets out there that try to be exhaustive, or suggest mapping shit to more convenient locations, but that is not the goal of this one. Everyone should use tmux for every connection, to every server, always. Memorizing this brings down the barrier to doing so.
Session is a set of windows, plus a notion of which window is current.
Window is a single screen covered with panes. (Once might compare it to a ‘virtual desktop’ or a ‘space’.)
Pane is a rectangular part of a window that runs a specific command, e.g. a shell.
The default prefix is ctrl-b
. This keystroke will prefix all keyboard shortcuts and tmux commands. Command mode is entered with ctrl-b :
and all commands listed below will begin with a :
while keyboard shortcuts will include the ctrl-b
. Anything else is expected to be entered on the shell.
Display a list of keyboard shortcuts:
ctrl-b ?
Learn tmux commands and settings:
:list-commands # Comments can be added after a hash
man tmux
View settings:
There are session settings, window settings, and server settings. You can read about them in
man tmux
by searching forset-option
. The latter 2 setting types can be viewed and set via-w
and-s
flags respectively. The-g
flag is used to show or set global settings rather than
:show -g # show session settings
:show -gw # show window settings
:show -gs # show server settings
Change settings:
:set <setting> <value> # set option for this session
:set -g prefix C-a # set option for all sessions
:set -w monitor-activity on # set option for this window
:set -gw mode-keys vi # set option for all windows
Any command mentioned in this list can be executed as tmux something
or ctrl-b :something
(or added to ~/.tmux.conf
).
Attach to a session if there is one, otherwise create an unnamed session:
tmux attach || tmux
Creating a named session (great for horror show gigs where you use a shared login):
tmux -s bruno
Create a new named session that shares all windows with an existing session, but has its own separate notion of which window is current:
tmux -s task2 -t bruno
Attach to a named session:
tmux attach -t bruno
Detach from a session:
ctrl-b d
Choose a session from a list:
ctrl-b s
Parenting:
ctrl-b c # Create new window
ctrl-b & # Kill the current window (all panes)
ctrl-b , # Rename the current window
Switch between windows:
ctrl-b n # Next window
ctrl-b p # Previous window
ctrl-b l # Last used window
ctrl-b w # Choose window from a list
ctrl-b 1 # Switch to window 0-9 by number
ctrl-b alt-n # Next window with a bell, activity or content alert
ctrl-b alt-p # Nrevious such window
Other:
Parenting:
ctrl-b q # display pane numbers for a short while
ctrl-b " # split vertically (top/bottom)
ctrl-b % # split horizontally (left/right)
ctrl-b x # kill the current pane
Switching between panes:
ctrl-b left # (or right, up, or down) go to the next pane
ctrl-b o # go to the next pane (cycle through all of them)
ctrl-b ; # go to the ‘last’ (previously used) pane
Moving panes around:
ctrl-b { # move the current pane to the previous position
ctrl-b } # move the current pane to the next position
ctrl-b ctrl-o # rotate window ‘up’ (i.e. move all panes)
ctrl-b alt-o # rotate window ‘down’
ctrl-b ! # break pane (move pane to a new window)
:move-pane -t :3.2
# split window 3's pane 2 and move the current pane there
Resizing panes:
ctrl-b alt-left # (or right, up or down) resize by 5 rows/columns
ctrl-b ctrl-left # (or right, up or down) resize by 1 row/column
Applying predefined layouts:
ctrl-b alt-1 # switch to even-horizontal layout
ctrl-b alt-2 # switch to even-vertical layout
ctrl-b alt-3 # switch to main-horizontal layout
ctrl-b alt-4 # switch to main-vertical layout
ctrl-b alt-5 # switch to tiled layout
ctrl-b space # switch to the next layout
Force a reload of the config file:
:source-file ~/.tmux.conf
Fix disassociated SSH agent/auth:
eval $(tmux showenv -s SSH_AUTH_SOCK)