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! Thanks for reading :P I just want to let you know that if you enjoyed this, you might also like this post on Sorting.

ABOUT THE AUTHOR RSS Feed Icon

I'm Bobby Yan, a programmer, music lover and web developer. I am currently working on IB Notes, a website with useful and concise study guides and notes for IB students. I have also built the Spanish Vocabulary Builder iOS app to help Spanish learners.

If you enjoyed this article, you should follow me on Twitter or sign up to get an email whenever I write something new:

Share this article with your friends: