Tmux Usage
tmux is a wonderful tool for terminal paneling and can also be used to detach and background a terminal window, similarly to how one might do with screen. The following guide details how I have used tmux over the years. Please feel free to add your own tips and tricks!
Abbreviations
My tmux is not necessarily the same as your tmux. As such, the following abbreviations are used to make this document configuration-agnostic:
| Abbreviation | Translation |
|---|---|
P | Prefix (e.g. Ctrl + b) |
M | Meta (e.g. Alt) |
Splitting
Conventionally, tmux panes can be split horizontally or vertically.
To split panes vertically, use P %.
To split panes horizontally, use P ".
Pane splitting can be nested to a large degree. If you split too much for your screen to handle, tmux will give you an error like “No space for new pane” and not much else will happen.
Navigation
Assuming you don’t have your tmux to support mouse click navigation, use P followed by an arrow key corresponding to the pane you want to move.
Don’t hold P in this case, otherwise you will adjust the pane. Speaking of…
Adjustment
If you want to resize a given pane, hold P and then press the corresponding arrow key for the direction you want to resize. You can hold the arrow key on some keyboards, but repeatedly pressing the arrow key is more reliable.
Reorganizing
You can reorganize panes into a variety of layouts. To do so, use any of the following (taken from the tmux manual page):
| Layout | Command |
|---|---|
| Even Horizontal | P M 1 |
| Even Vertical | P M 2 |
| Main Horizontal | P M 3 |
| Main Vertical | P M 4 |
| Tiled | P M 5 |
Attachment
To detach from a tmux pane, use P d.
To list detached tmux panes, use tmux list-sessions from outside of a tmux instance, or P s from within a tmux session.
To attach to a detached tmux pane, use tmux attach -t <id>, where <id> is the number shown in the session listing.
Miscellany
A few miscellaneous things.
P z will expand the current pane to take the full screen. Useful if you want to briefly move your terminal to see another window.
P t will open a clock. Useful if you… need a clock, I guess?