clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Tmux cheat sheet

Filed under: Cheat sheets— Tagged with: tmux, keyboard

A searchable tmux keyboard shortcut and command reference.

Sessions
CommandDescription
$ tmux, $ tmux new, $ tmux new-session, : newStart a new session
$ tmux new -s testSes, : new -s testSesStart a new named session
$ tmux kill-ses -t testSes, $ tmux kill-session -t testSesKill session testSes
$ tmux kill-session -aKill all sessions but the current
$ tmux kill-session -a -t testSesKill all sessions but testSes
Ctrl+b $Rename the session
Ctrl+b dDetach from session
: attach -dDetach others clients on the session
$ tmux -ls, $ tmux list-sessions, Ctrl+b sShow all sessions
$ tmux a, $ tmux at, $ tmux attach, $ tmux attach-sessionAttach to last session
$ tmux a -t testSes, $ tmux at -t testSes, $ tmux attach -t testSes, $ tmux attach-session -t testSesAttach to a session called testSes
Ctrl+b (Move to the previous session
Ctrl+b )Move to the next session
Windows
CommandDescription
$ tmux new -s testSes -n testWinStart a new session called testSes and window testWin
Ctrl+b cNew window
Ctrl+b ,Rename the current window
Ctrl+b &Close the current window
Ctrl+b pGo to the previous window
Ctrl+b nGo to the next window
Ctrl+b 0 ... 9Switch/select window by number
: swap-window -s 2 -t 1Reorder windows, swap window number 2 (source) and 1 (destination)
: swap-window -t -1Move the current window to left by one
Panes
CommandDescription
Ctrl+b ;Toggle last active pane
Ctrl+b %Split pane vertically
Ctrl+b "Split pane horizontally
Ctrl+b {Move the current pane left
Ctrl+b }Move the current pane right
Ctrl+b ➡︎, Ctr➡l+b ⬅︎, Ctrl+b ⬆︎, Ctrl+b ⬇︎Switch to pane to the direction
: setw synchronize-panesToggle synchronize-panes (sends a command to all panes)
Ctrl+b SpaceToggle between pane layouts
Ctrl+b oSwitch to next pane
Ctrl+b qShow pane numbers
Ctrl+b b q 0 ... 9Switch/select pane by number
Ctrl+b zToggle pane zoom
Ctrl+b !Convert pane into a window
Ctrl+b ⬆︎, Ctrl+b Ctrl+⬆︎, Ctrl+b+⬇︎, Ctrl+b Ctrl+⬇︎Resize current pane height (holding second key is optional)
Ctrl+b ➡︎, Ctrl+b Ctrl+➡︎, Ctrl+b+⬅︎, Ctrl+b Ctrl+⬅︎Resize current pane width (holding second key is optional)
Ctrl+b xClose current pane
Copy mode
CommandDescription
: setw -g mode-keys viUse vi keys in buffer
Ctrl+b [Enter the copy mode
Ctrl+b PgUpEnter copy mode and scroll one page up
qQuit copy mode
gGo to top line
GGo to bottom line
⬆︎Scroll up
⬇︎Scroll down
hMove cursor left
jMove cursor down
kMove cursor up
lMove cursor right
wMove cursor forward one word
bMove cursor backward one word
/Search forward
?Search backwards
nNext keyword occurrence
NPrevious keyword occurrence
SpaceStart selection
EscClear selection
EnterCopy selection
Ctrl+b ]Paste contents of buffer_0
: show-bufferdisplay buffer_0 contents
: capture-paneCopy entire visible contents of pane into a buffer
: list-buffersShow all buffers
: choose-bufferShow all buffers and paste selected
: save-buffer buffer.txtSave buffer contents to buffer.txt
: delete-buffer -b 1Delete buffer_1
Misc.
CommandDescription
Ctrl+b :Enter the command mode
: set -g OPTIONSet OPTION for all sessions
: setw -g OPTIONSet OPTION for all windows
Help
CommandDescription
$ tmux infoShow every session, window, pane, and so on.
Ctrl+b ?Show shortcuts

What is Tmux?

Tmux is a terminal multiplexer. For example you can open a tmux session and it will keep all the processes running even if you close the terminal, so you can later on attach back to the session and resume where you left off. This way you can leave long lasting tasks running, for examples an Irssi IRC client etc.

Besides that, tmux can serve as a window manager, you can split the terminal into panes (think of split view), or open new windows (think of tabs). See my post on how to install and use tmux for more detailed info.

Use with Alfred

A screen shot of Alfred app’s search bar

You can quickly search this guide from Alfred if you setup a custom search. Click here to add it automatically. Or see instructions below how to add it manually.

How to add custom Alfred search manually
  1. Pop open Alfred settings.
  2. Go to "Web Search".
  3. Click "Add Custom Search".
  4. In the "Search URL" field paste: https://clubmate.fi/tmux-cheat-sheet?s={query}.
  5. Name it something like: "Search tmux cheat sheet for {query}"
  6. Give it a suitable keyword like "tmux", and save.
  7. Then type something like "tmux kill" into Alfred, et voilà.
A screen shot of Alfred app
How to add tmux cheat sheet as custom search engine in Alfred

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @intterne if you want to make a correction etc.

  • © 2022 Antti Hiljá
  • About
  • Follow my new Twitter account → @intterne
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!