Skip to content

Instantly share code, notes, and snippets.

@fstab
Last active October 28, 2022 12:47
Show Gist options
  • Save fstab/b212c36ba8486c7ed212d7f23c8aa5e2 to your computer and use it in GitHub Desktop.
Save fstab/b212c36ba8486c7ed212d7f23c8aa5e2 to your computer and use it in GitHub Desktop.
tmux cheatsheet

Config File

The default <prefix> key is Ctrl-b. To get more screen-like behavior, change the <prefix> to Ctrl-a in ~/.tmux-conf like this:

unbind C-b
set -g prefix C-a

In Screen, to send Ctrl-a to an application, you must hit Ctrl-a a. Enable this for tmux using the following ~/.tmux-conf entry:

bind-key a  send-prefix

Vi style navigation between panes (splits)

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

Sessions

  • start new session: tmux
  • start new named session: tmux new -s myname
  • attach to running session tmux a (or at, or attach)
  • attach to running named session: tmux a -t myname
  • list sessions: tmux ls
  • kill session: tmux kill-session -t myname
  • Kill all tmux sessions: tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill

Windows (tabs)

Note <prefix> is Ctrl-b by default unless configured otherwise, see above.

  • Create new window: <prefix> c
  • Next window: <prefix> n
  • Previous window: <prefix> p
  • Name window: <prefix> ,

Panes (Splits)

  • Split pane horizontally: <prefix> "
  • Split pane vertically: <prefix> %
  • Switch pane: <prefix> <arrow-key> (release Ctrl-b, then press an arrow key)
  • Resize pane: <prefix>-<arrow-key> (hold Ctrl-b while pressing the arrow key)
  • Toggle full screen for current pane (zoom): <prefix> z
  • Enter scroll mode: <prefix> [, then use arrow keys or page keys to scroll. Press q to quit scroll mode.

Windows (tabs) and Panes (Splits)

  • Move current pane to new window: <prefix> !

Copy-and-Paste

See https://www.devroom.io/2017/03/22/tmux-and-vim-copy-and-paste-on-macos-sierra/, but use new syntax as shown in alaska's comment here tmux/tmux#754

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment