Basics

  • Start an unnamed session: tmux
  • Start a named session: tmux new -s <name>
  • Attach: tmux a #
  • Attach to named session: tmux a -t <name>
  • Detch from session: Ctrl + b (or your custom <prefix>), then d
  • List all sessions: tmux ls
  • Kill a named session: tmux kill-ses -t <name>
  • Kill the server: tmux kill-server

Shortcuts

Shortcuts for Sessions
<prefix>, d # detach from session
<prefix>, s # select from sessions
<prefix>, $ # rename session

<prefix>, ( # previous session
<prefix>, ) # next session
<prefix>, L # last session
Shortcuts for Windows
<prefix>, c 	# create new window
<prefix>, w 	# select from windows
<prefix>, , 	# rename window
<prefix>, & 	# kill window

<prefix>, p 	# previous window
<prefix>, n 	# next window
<prefix>, l 	# last window
<prefix>, [0-9]	# go to [0-9]th window
Shortcuts for Panes
<prefix>, % # vertical split
<prefix>, " # horizontal split
<prefix>, q # show pane numbers (when numbers are show, press number to select pane)
<prefix>, x # kill pane
<prefix>, o # swap panes
<prefix>, { # (Move the current pane left)
<prefix>, } # (Move the current pane right)
<prefix>, z # toggle pane zoom
<prefix>, <space> # toggle b/w layouts

Useful Commands

Entering the <prefix> gets you into the command mode, then

:new-window -a		# insert new window right next to current
:swap-window -t [pos]	# move curr window

Miscellaneous

Customizing <prefix>

If you wish to change the prefix from Ctrl + b to something like Ctrl + a, which some people prefer, you could create a file ~/.tmux.conf with the following:

# Remap tmux Prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
1-indexing Windows

And if you don’t want the 0-indexing for your windows, since 1 is easier to press when switching, add the following as well:

# 1-index Windows
set -g base-index 1

When you are done, be sure

:source-file ~/.tmux.conf

Hey, kudos for making it this far! If you've liked this, you might also like How to Completely Remove VirtualBox from macOS.