TMUX Reference

A quick reference for all the TMUX shortcuts.

Sessions

Create and delete

Create new session

  • tmux
  • tmux new
  • tmux new-session
  • new

Create new session with name

  • tmux new-session -s NAME
  • new -s NAME

Create new session with session and window name

  • tmux new -s S_NAME -n W_NAME

Create or attach to session with name

  • tmux new-session -A -s NAME

Kill session

  • kill-session

Kill session by name

  • tmux kill-session -t NAME
  • tmux kill-ses -t NAME

Kill other sessions

  • tmux kill-session -a

Kill all sessions except

  • tmux kill-session -a -t NAME

List sessions

  • tmux ls
  • tmux list-sessions
  • ctrl + b,s

List sessions w/ windows

  • ctrl + b,w

Goto previous session

  • ctrl + b,(
Goto next session

For this to be helpful, you need to know what the next session is. That can be hard to find if you rename sessions because ctrl + b + s ‘s default order is by name.


To change the default order to be by index, you can use add this snippet to your ~/tmux.conf

bind s choose-tree -sZ -O index

From within the choose-tree menu, you can temporarily toggle through order with ctrl + b + shift + o.

  • ctrl + b,)

Goto last active session

  • ctrl + b,L

Attach to last session

  • tmux a
  • tmux at
  • tmux attach
  • tmux attach-session

Attach to session by NAME

  • tmux a -t NAME
  • tmux at -t NAME
  • tmux attach -t NAME
  • tmux attach-session -t NAME

Detach from session

  • ctrl + b,d

Detach others on the session (todo)

  • attach -d

Show list of sessions to detatch from

  • ctrl + b,D

Organization

Rename session

  • ctrl + b,$
  • rename-session NAME

Windows

Create and delete

Create window

  • ctrl + b,c

Kill window

  • ctrl + b,&

Search for window

  • ctrl + b,f

List windows

  • ctrl + b,w

Goto previous window

  • ctrl + b,p

Goto next window

  • ctrl + b,n
Goto prev/next window (VIM)

This requires updating your tmux.conf

bind -n M-H previous-window
bind -n M-L next-window
  • ctrl + shift + h
  • ctrl + shift + l

Goto last active window

  • ctrl + b,l

Switch window by number

  • ctrl + b,0 … 9

Organization

Rename current window

  • ctrl + b,,
Swap window order (absolute)
  • -s = source
  • -t = target
  • swap-window -s 2 -t

Swap window order (relative)

  • swap-window -t -1

Move window between sessions (by name)

  • movew -s foo:0 -t bar:9

Move window between sessions (by number)

  • movew -s 0:0 -t 1:9

Reposition window in the current Session (todo)

  • move-window -s src_session:src_window
  • movew -s 0:9

Renumber windows to remove gap in the sequence (todo)

  • move-window -r
  • movew -r

Misc

Display information about the current window

  • ctrl + b,i

Panes

Create and kill

Create horizontal split

  • ctrl + b,%
  • split-window -h

Create vertical split

  • ctrl + b,
  • split-window -v

Kill pane

  • ctrl + b,x

Goto pane in direction

  • ctrl + b,
  • ctrl + b,
  • ctrl + b,
  • ctrl + b,
Goto pane in direction (VIM)

This requires updating your tmux.conf

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
  • ctrl + h
  • ctrl + j
  • ctrl + k
  • ctrl + l
Goto next pane

Fun fact: there is no builtin shortcut for going to prev pane.

  • ctrl + b,o

Goto last active pane

  • ctrl + b,;

Show pane numbers

  • ctrl + b,q

Switch/select pane by number

  • ctrl + b,0…9

Toggle pane zoom

  • ctrl + b,z

Organization

Resize current pane

Note: on MacOS you have to disable Mission Control keyboard shortcuts for these to work. (link)

  • ctrl + b + ↑
  • ctrl + b + →
  • ctrl + b + ↓
  • ctrl + b + ←
  • ctrl + b,ctrl + ↑
  • ctrl + b,ctrl + →
  • ctrl + b,ctrl + ↓
  • ctrl + b,ctrl + ←

Spread panes out evenly

  • ctrl + b,E

Swap current pane with prev

  • ctrl + b,{

Swap current pane with next

  • ctrl + b,}

Rotate panes clockwise

  • ctrl + b,ctrl + o

Rotate panes counter clockwise

  • ctrl + b,option + o

Rearrange panes in 1 of 7 layout presets

  • ctrl + b,option + 0…7

Cycle through layout presets

  • ctrl + b,space

Window

Join two windows as panes (Merge window 2 to window 1 as panes) ????

  • join-pane -s 2 -t 1

Move pane from one window to another


The example moves pane 1 in window 2 to window 1 right after the 3rd pane.

  • join-pane -s 2.1 -t 1.3

Toggle synchronize-panes


Setting this option on will send the same command to each pane.

  • setw synchronize-panes

Convert pane into a window

  • ctrl + b,!

Copy Buffer

Aside from entering copy mode and pasting your most recent buffer, all these commands assume that you are already in copy mode.

Unless specified VIM keybindings are enable with set -g mode-keys vi. This section assumes you have this enabled. I would recommend adding this to your ~/.tmux.conf file.

Enter copy mode

  • ctrl + b,]

Exit copy mode

  • ctrl + b,esc
  • ctrl + b,q (VIM)

Navigate in copy mode

  • ctrl + ↑
  • ctrl + →
  • ctrl + ↓
  • ctrl + ←
  • h (VIM)
  • j (VIM)
  • k (VIM)
  • l (VIM)
Start selection

This VIM keybinding is custom and can be bound with

bind-key -T copy-mode-vi 'v' send -X begin-selection
(Link)
  • space
  • v (VIM)
Copy selection

This VIM keybinding is custom and can be bound with

bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
(Link)
  • enter
  • y (VIM)

Search window history

  • ?
  • / (VIM)

Goto top of history

  • g

Goto bottom of history

  • G

Goto next search result

  • n

Goto previous search result

  • N

Paste most recent buffer

  • ctrl + b,]

Open copy history to paste

  • ctrl + b,=

General

List all keybindings

  • ctrl + b,?

Show the time

  • ctrl + b,t

Show previous messages from TMUX

  • ctrl + b,~
Clearing window history

You can also bing this to a specific key with something like ctrl + l.

bind-key -n C-l send-keys C-l \; send-keys -R \; clear-history

(link)

  • tmux clear-history
  • clear-history
  • ctrl + b,ctrl + l (w/ config)
Sourcing your tmux.conf (link)
  • tmux source-file ~/.tmux.conf
  • tmux set -g prefix C-a
  • source-file ~/.tmux.conf
  • set -g prefix C-a