Terminal-friendly tmux cheatsheet
by Tullio Facchinetti
I typically use tmux when working on remote servers, but sometimes I don’t remember keybindings or commands for some functions that I rarely use.
Since I find the tmux help/manpage rather confused, I usually revert to this cheatsheet, which is very well organized. However, I’d want to avoid to rely on a webpage for documentation that I would better checkout in the terminal, maybe using grep.
Solution
For this reason I packaged a text file with the same content reported in the above mentioned cheatsheet, with a format that is terminal friendly.
This is an excerpt of the file:
-------------------------------------
Sessions
-------------------------------------
$ tmux start a new session
$ tmux new start a new session
$ tmux new-session start a new session
: new start a new session
$ tmux new -s mysession start a new session with the name mysession
: new -s mysession start a new session with the name mysession
$ tmux kill-ses -t mysession kill/delete session mysession
$ tmux kill-session -t mysession kill/delete session mysession
$ tmux kill-session -a kill/delete all sessions but the current
Ctrl + b $ rename session
Ctrl + b d detach from session
Organization for effective search
I organized the content so that every explanation is on the same line of the corresponding keybinding. Moreover, the “action” (e.g., open, kill, start, etc.) precedes the “target object” (e.g., window, pane, etc.).
In this way, it is possible to grep the cheatsheet with a pattern like action.*object
.
For example
$ grep "close.*window" tmux-cheatsheet.txt
Ctrl + b & close current window
or
$ grep "resize.*pane" tmux-cheatsheet.txt
Ctrl + b + up-arrow resize current pane height (holding second key is optional)
Ctrl + b Ctrl + up-arrow resize current pane height (holding second key is optional)
Ctrl + b + down-arrow resize current pane height (holding second key is optional)
Ctrl + b Ctrl + down-arrow resize current pane height (holding second key is optional)
Ctrl + b + right-arrow resize current pane width (holding second key is optional)
Ctrl + b Ctrl + right-arrow resize current pane width (holding second key is optional)
Ctrl + b + left-arrow resize current pane width (holding second key is optional)
Ctrl + b Ctrl + left-arrow resize current pane width (holding second key is optional)
Download
To use it locally, you can either clone the repository from github (or download the raw text file) or download the text file.
Alternatives
There are several other options. Beside the already mentioned cheatsheet, there is cheat.sh/tmux that is great, although it is not as grep-friendly as mine.