Skip to content

Instantly share code, notes, and snippets.

@poltak
Forked from andreyvit/tmux.md
Last active January 3, 2016 11:59
Show Gist options
  • Save poltak/8460018 to your computer and use it in GitHub Desktop.
Save poltak/8460018 to your computer and use it in GitHub Desktop.

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

I'm going to assume that C-f is your prefix.

Sessions, windows, panes

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.

Getting help

Display a list of keyboard shortcuts:

C-f ?

Navigate using Vim or Emacs shortcuts, depending on the value of mode-keys. Emacs is the default, and if you want Vim shortcuts for help and copy modes (e.g. j, k, C-u, C-d), add the following line to ~/.tmux.conf:

setw -g mode-keys vi

Any command mentioned in this list can be executed as tmux something or C-f :something (or added to ~/.tmux.conf).

Managing sessions

Creating a session:

tmux new-session -s work

Create a new session that shares all windows with an existing session, but has its own separate notion of which window is current:

tmux new-session -s work2 -t work

Attach to a session:

tmux attach -t work

Detach from a session: C-f d.

Switch between sessions:

C-f (          previous session
C-f )          next session
C-f L          ‘last’ (previously used) session
C-f s          choose a session from a list

Other:

C-f $          rename the current session

Managing windows

Create a window:

C-f c          create a new window

Switch between windows:

C-f 1 ...      switch to window 1, ..., 9, 0
C-f 9
C-f 0
C-f p          previous window
C-f n          next window
C-f l          ‘last’ (previously used) window
C-f w          choose window from a list

Switch between windows with a twist:

C-f M-n        next window with a bell, activity or
               content alert
C-f M-p        previous such window

Other:

C-f ,          rename the current window
C-f &          kill the current window

Managing split panes

Creating a new pane by splitting an existing one:

C-f s          split vertically (top/bottom)
C-f v          split horizontally (left/right)

Switching between panes:

C-f h          go to the next pane on the left
C-f l          (or one of these other directions)
C-f k
C-f j
C-f o          go to the next pane (cycle through all of them)
C-f ;          go to the ‘last’ (previously used) pane

Moving panes around:

C-f {          move the current pane to the previous position
C-f }          move the current pane to the next position
C-f C-o        rotate window ‘up’ (i.e. move all panes)
C-f M-o        rotate window ‘down’
C-f !          move the current pane into a new separate
               window (‘break pane’)
C-f :move-pane -t :3.2
               split window 3's pane 2 and move the current pane there

Resizing panes:

C-f M-up, C-f M-down, C-f M-left, C-f M-right
               resize by 5 rows/columns
C-f C-up, C-f C-down, C-f C-left, C-f C-right
               resize by 1 row/column

Applying predefined layouts:

C-f M-1        switch to even-horizontal layout
C-f M-2        switch to even-vertical layout
C-f M-3        switch to main-horizontal layout
C-f M-4        switch to main-vertical layout
C-f M-5        switch to tiled layout
C-f space      switch to the next layout

Other:

C-f x          kill the current pane
C-f q          display pane numbers for a short while
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment