Cheat Sheet for tmux

  1. Cheat Sheet
    1. Session Control
    2. Pane Control
    3. Window Control
    4. Copy-Mode (vi)
    5. Copy-Mode (Emacs)

This post discusses tmux, a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be run simultaneously in a single window.
Other uses include executing remote commands in a session on a server through an SSH connection, disconnecting, and later returning to the session to see the command output.

Tmux is a rewrite of GNU Screen.

First thing is first- add this to your ~/.tmux.conf

setw -g mode-keys vi
set -g history-limit 10000

# bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -se c -i' # linux
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'pbcopy' # mac

Cheat Sheet

A printable version of this cheat sheet is available here.

Session Control

Session Control (from the command line)Description
tmuxStart a new session
tmux new -s <session-name>Start a new session with the name chosen
tmux lsList all sessions
tmux attach -t <target-session>Re-attach a detached session
tmux attach -d -t <target-session>Re-attach a detached session (and detach it from elsewhere)
tmux kill-session -t <target-session>Delete session

Pane Control

Pane ControlDescription
Ctrl b, "Split pane horizontally
Ctrl b, %Split pane vertically
Ctrl b, oNext pane
Ctrl b, ;Previous pane
Ctrl b, qShow pane numbers
Ctrl b, zToggle pane zoom
Ctrl b, !Convert pane into a window
Ctrl b, xKill current pane
Ctrl b, Ctrl OSwap panes
Ctrl b, tDisplay clock
Ctrl b, qTranspose two letters (delete and paste)
Ctrl b, {Move to the previous pane
Ctrl b, }Move to the next pane
Ctrl b, SpaceToggle between pane layouts
Ctrl b, ↑Resize pane (make taller)
Ctrl b, ↓Resize pane (make smaller)
Ctrl b, ←Resize pane (make wider)
Ctrl b, →Resize pane (make narrower)

Window Control

Window ControlDescription
Ctrl b, cCreate new window
Ctrl b, dDetach from session
Ctrl b, ,Rename current window
Ctrl b, &Close current window
Ctrl b, wList windows
Ctrl b, pPrevious window
Ctrl b, nNext window

Copy-Mode (vi)

Copy-Mode (vi)Description
Ctrl b, [Enter copy mode
Ctrl b, GBottom of history
Ctrl b, gTop of history
Ctrl b, EnterCopy selection
Ctrl b, pPaste selection
Ctrl b, kCursor Up
Ctrl b, jCursor Down
Ctrl b, hCursor Left
Ctrl b, lCursor Right

Copy-Mode (Emacs)

Copy-Mode (Emacs)Description
Ctrl b, [Enter copy mode
Ctrl b, M-<Bottom of history
Ctrl b, M->Top of history
Ctrl b, M-mBack to indentation
Ctrl b, M-wCopy selection
Ctrl b, M-yPaste selection
Ctrl b, Ctrl gClear selection
Ctrl b, M-RCursor to top line
Ctrl b, M-rCursor to middle line
Ctrl b, ↑Cursor Up
Ctrl b, ↓Cursor Down
Ctrl b, ←Cursor Left
Ctrl b, →Cursor Right