Skip to content
Austin Kong edited this page Jul 28, 2016 · 3 revisions

tmux Cheatsheet

tmux commands

tmux [command]     # Run a command
                   # 'tmux' with no commands will create a new session
  new              # Create a new session
   -s "Session"    # Create named session
   -n "Window"     # Create named Window
   -c "/dir"       # Start in target directory
  attach           # Attach last/available session
  attach-session|a|at
   -t "#"          # Attach target session
   -d              # Detach the session from other instances
  ls               # List open sessions
   -a              # List all open sessions
  lsw              # List windows
   -a              # List all windows
   -s              # List all windows in session
  lsp              # List panes
   -a              # List all panes
   -s              # List all panes in session
   -t              # List all panes in target
  kill-window      # Kill current window
   -t "#"          # Kill target window
   -a              # Kill all windows
   -a -t "#"       # Kill all windows but the target
  kill-session     # Kill current session
   -t "#"          # Kill target session
   -a              # Kill all sessions
   -a -t "#"       # Kill all sessions but the target

tmux list-keys                #lists out every bound key and the tmux command it runs
tmux list-commands            #lists out every tmux command and its arguments
tmux info                     #lists out every session, window, pane, its pid, etc.
tmux source-file ~/.tmux.conf #reloads the current tmux configuration (based on a default tmux config)

Keyboard commands

C-b : prefix
C-a : prefix (CUSTOM)

C-b : `send-prefix`

C-z : suspend client
d   : tmux detach
D   : choose a client to detach
s   : list sessions
$   : name session
L   : switch the attached client back to the last session.
t   : clock
?   : help
:   : prompt
~   : show last message
r   : force redraw of the attached client.
r   : reload tmux-conf (CUSTOM)

a   : go to last swapped tab

c   : `new-window`
w   : list windows and select interactively
&   : kill window
,   : `rename-window`
n   : next window
p   : prev window
0-9 : `select-window -t :0-9`

`swap-window -s 3 -t 1` : swap windows 3 and 1
`swap-window -t 0` : swap the current window with the top window
`move-window -t 0`

%   : split pane horizontal `split-window -h`
\"  : split pane vertical `split-window`
C-a : cycle panes (CUSTOM)
C-o : swap panes `select-pane -t :.+`
o   : next pane
;   : prev pane
q   : pane number
{   : move current pane left `swap-pane -[UDLR]`
}   : move current pane right
x   : kill current pane
z   : toggle pane zoom
+   : break pane into window (e.g. to select text by mouse to copy)
-   : restore pane from window
space : toggle between layouts
`tmux select-pane -[UDLR]` #selects the next pane in the specified direction
`tmux select-pane -t :.+`  #selects the next pane in numerical order

Up, Down         # Change to the pane above, below, left, or right
Left, Right
M-1 to M-5       # Arrange panes:
                 # 1) even-horizontal
                 # 2) even-vertical
                 # 3) main-horizontal
                 # 4) main-vertical
                 # 5) tiled
C-Up, C-Down     # Resize the current pane in steps of one cell
C-Left, C-Right
M-Up, M-Down     # Resize the current pane in steps of five cells
M-Left, M-Right
M-o              # Rotate the panes in the current window backwards

Misc

`setw -g mode-keys vi`
[  : start copy mode
q quit copy mode (no prefix?)
Page Up     Enter copy mode and scroll one page up.
Up, Down
Left, Right
]  : paste buffer

Function                vi             emacs
Back to indentation     ^              M-m
Clear selection         Escape         C-g
Copy selection          Enter          M-w
Cursor down             j              Down
Cursor left             h              Left
Cursor right            l              Right
Cursor up               k              Up
Cursor to bottom line   L
Cursor to middle line   M              M-r
Cursor to top line      H              M-R
Delete entire line      d              C-u
Delete to end of line   D              C-k
End of line             $              C-e
Goto line               :              g
Half page down          C-d            M-Down
Half page up            C-u            M-Up
Next page               C-f            Page down
Next word               w              M-f
Paste buffer            p              C-y
Previous page           C-b            Page up
Previous word           b              M-b
Quit mode               q              Escape
Scroll down             C-Down or J    C-Down
Scroll up               C-Up or K      C-Up
Search again            n              n
Search backward         ?              C-r
Search forward          /              C-s
Start of line           0              C-a
Start selection         Space          C-Space
Transpose chars                        C-t

PuTTY tips - shift overrides in terminal mouse behaviour

Link dump

Setup tmux

[Installing tmux without admin] (https://gist.github.com/albd/d397678a499f6d434558)

Install tmux locally

[tmux plugin manager] (https://github.com/tmux-plugins/tpm)

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
prefix + I #Installs new plugins from GitHub or any other git repository and refreshes TMUX environment
prefix + U #updates plugin(s)
prefix + alt + u #remove/uninstall plugins not on the plugin list

[tmux sensible] (https://github.com/tmux-plugins/tmux-sensible)

Clone this wiki locally