logo

Cheatsheets - tmux

Last Updated: 2023-01-10
# start new
$ tmux

# start new with session name:
$ tmux new -s foo

# list sessions
$ tmux ls

# rename: 
$ tmux rename-session -t 0 foo

# attach
$ tmux a  #  (or at, or attach)
$ tmux attach -t 0
$ tmux a -t foo
$ tmux attach-session -t 0

# detach
$ tmux detach
# or `Ctrl-b d`

# kill
$ tmux kill-session -t myname
# kill all
$ tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill

C-b = Ctrl-b

Sessions

  • :new new session
  • C-b s list sessions
  • C-b $ name session

Windows (tabs)

  • C-b c: create a window
  • C-b n: next window
  • C-b p: previous window
  • C-b 1: jump to window 1
  • C-b ,: name window
  • C-b w: list windows
  • C-b f: find window
  • C-b &: kill window
  • C-b .: move window - prompted for a new number
  • :movew<CR>: move window to the next unused number

Panes (splits)

  • C-b %: vertical split
  • C-b ": horizontal split
  • C-b o: swap panes
  • C-b q: show pane numbers
  • C-b x: kill pane
  • C-b +: break pane into window (e.g. to select text by mouse to copy)
  • C-b -: restore pane from window
  • C-b ⍽: space - toggle between layouts
  • C-b {: Move the current pane left
  • C-b }: Move the current pane right
  • C-b z: toggle pane zoom

Resize Panes

:resize-pane -D (Resizes the current pane down)
:resize-pane -U (Resizes the current pane upward)
:resize-pane -L (Resizes the current pane left)
:resize-pane -R (Resizes the current pane right)
:resize-pane -D 20 (Resizes the current pane down by 20 cells)
:resize-pane -U 20 (Resizes the current pane upward by 20 cells)
:resize-pane -L 20 (Resizes the current pane left by 20 cells)
:resize-pane -R 20 (Resizes the current pane right by 20 cells)
:resize-pane -t 2 20 (Resizes the pane with the id of 2 down by 20 cells)
:resize-pane -t -L 20 (Resizes the pane with the id of 2 left by 20 cells)

Window/pane surgery

:joinp -s :2<CR>  move window 2 into a new pane in the current window
:joinp -t :1<CR>  move the current pane into a new pane in window 1

Misc

  • C-b d: detach
  • C-b t: big clock
  • C-b ?: list shortcuts
  • C-b :: prompt