My Tmux “cheat sheet”

I work a lot in terminal windows and sometimes from different locations. Starting new sessions and logging in to every server (sometimes up to 10 servers with different users) can be quite tiresome. In the beginning I was a fan of the GNU Screen program but after I found Tmux I never looked back. Now dont get me wrong, GNU Screen is a great program but I believe that Tmux handles splits, windows and commands a little better. Here are my most used commands i Tmux

Start tmux

tmux

Start saved session

tmux attach

Display sessions

tmux ls

Start a new shared session

tmux -S /tmp/shared_session
chmod 777 /tmp/shared_session #Anyone can now join your session

Attach to a shared session

tmux -S /tmp/shared_session attach

Command mode

ctrl + b

All commands below start with this key combination. It makes Tmux waiting for a command to run

Exit session (session is automatically saved)

ctrl + b + d

Help screen

ctrl + b + ?

This will show you alla commands available. If you make changes to command in the configuration file you will also see them here. To exit the help press q

Create new window command

ctrl + b + c

Rename window you are currently in

crtl + b + , (comma)

Switch between windows (You can see all created windows in the bottom list of Tmux window)

ctrl + b + 0-9 #eg ctrl + b + 1 will take you to window number 1 

Switch between panes (ctrl + b + arrow keys)
* Key Up to switch to pane above
* Key Down to switch to pane below
* Key Right to switch to pane to the right
* Key Left to switch to pane to the left

If you stand in the pane the most to the right and press to go right the cursor will move to the leftmost pane. Same goes for all directions.

Scroll mode (this let you scroll window/pane by using Page Up/Page Down and the Up and Down keys)

ctrl + b + PageUp

Exit scroll mode

Esc or q key

The following commands depend om my config (default options are found in the help menu if you are not using my config)

Split window horizontal

ctrl + b + h

Split window vertically

ctrl + b + v

Grow pane horizontally

ctrl +b + + (plus)

Shrink pane horizontally

ctrl + b + - (minus)

Grow pane vertically

ctrl + b + *

Shrink pane vertically

ctrl + b + /

My Tmux configuration file (place it in your home directory named .tmux.conf to use it)

# Splitting windows into panes with h and v 
bind-key h split-window -v
bind-key v split-window -h

# Set up resize-pane keys
bind-key + resize-pane -D 3
bind-key / resize-pane -L 3
bind-key - resize-pane -U 3
bind-key * resize-pane -R 3

NEW! For all you spanish speaking people out there, my friend Stephen Chow has translated this post in his blog: stephenchow.es

  1. Thank you so much. I’ve been using Tmux for a while now and this is the best cheat sheet out there. Thank you so much.

  2. Hello, I just recently started using tmux. And it s very helpful your compilation. Do you mind if I duplicate and translate comments in spanish and put it on my blog? Obviusly crediting you.
    Thanks

  3. Thanks Niklas. You ended my search for small startup guide of tmux, got ur blog aftr 20-30 mins of googling..Thank you very much again..Keep posting

  4. sameer gawande

    the default way to split tmux is

    crtl + b + ” (horizontal)
    ctrl + b % (vertical)
    ctrl + b ! (to cancel the split
    ctrl + b o (toggle between split screens)

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>