Tmux - the terminal multiplexer.

Other cheatsheet.

Tmux has a few concepts anyone should be familiar with:

  • session
    • connection to the windows you’re working with
  • window
    • single screen you’re working with
  • pane
    • part of window - “split”

Tmux can also run multiple servers on one machine. with tmux -L <server_name>.

Some commands

All shortcuts do assume default Tmux leader - C-b.

ShortcutCommandExplanation
C-b :Enter tmux command prompt
C-b ,:rename-window
C-b !:break-panepush it to new window
C-b j:join-pane <to-pane-nr>join pane to current window
C-b .change pane number
C-b $:rename-session […]
C-b {Swap active pane with above
C-b }Swap active pane with below
C-b wChoose a window from a list
C-b ?Show those bindings
C-b ddetach form current session
-tmux lslist sessions
-tmux attach [sessionId]attach to existing session
-:set synchronized-panesSynchronize input in all visible panes
C-b mToggle marked pane - remove/add ugly bar
C-b [Enter caret mode (begin selection for copy)
C-b ]Paste copied via tmux

Minimal config

We can test it with running tmux -L my-test-server -f <file-with-alternate-config>

set -g mouse on
set-option -sa terminal-overrides ",xterm*:Tc"

set -g default-terminal "xterm-256color"
setw -g mode-keys vi


unbind-key -T copy-mode-vi v

bind-key -T copy-mode-vi 'v' send -X begin-selection # Begin selection in copy mode.
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle # Begin selection in copy mode.
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' # Yank selection to system clipboard (only use if you have xclip installed).

# bind-key -T copy-mode-vi 'y' send -X copy-selection # Yank selection in copy mode - mac / non xorg.