When you launch tmux, it will create a tmux-server, a session, a window and a pane.
The tmux server manage every single tmux session. If you kill it, you kill every session as well. You can try it by yourself with the command tmux kill-server.
We spoke about sessions before. You can detach them from a client (and let them run in the background) and attach them back.
In tmux, a window represent an entire screen. You can have multiple windows open in one session. You can access each window via a tab in the tmux status bar, at the bottom.
You can split your windows in panes to have multiple terminals on one screen. These panes are independent by default, but you can synchronize them too.
The power of tmux doesn’t stop here. There are many tools out there which allow you to automate tmux session creation via YAML (or JSON) config files.
You can automate everything, from the number of windows and panes you want to, to the command lines to execute in which pane.
The most known tools to create sessions from config files are tmuxinator, tmuxp and smug.
for i in {0..255}; do
printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\n"
donetmux list-keys
| Alias | Signification |
|---|---|
| set | set-option |
| setw | set-window-option |
| run | run-shell |
| bind | bind-key |
| Flag | Signification |
|---|---|
-r |
enable keep hitting bind key without prefix (repeatable) |
-n |
enable bind key without prefix |
-g |
global |
| Command | Signification |
|---|---|
tmux new -s <sessionName> |
Start a new session with the given name |
tmux ls-sessions |
List tmux sessions |
tmux a -t <sessionName> |
Attach to a named session (by default, the name is the session index) |
tmux kill-session -t <sessionName> |
Kill a session (by default, the name is the session index) |
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill |
Kill all tmux sessions |
By default, all commands listed below must be prefixed by the tmux <prefix>.
| Shortcut | Signification |
|---|---|
: |
Open command prompt |
:show-options -g |
Display global options |
:show-options -w |
Display window options |
:show-options -s |
Display server options |
? |
List shortcuts |
t |
Display a big clock |
| Session | |
:new<CR> |
New session |
s |
Choose session |
$ |
Rename session |
d |
Detach session |
| Window | |
c |
Create window |
w |
Choose window |
n |
Next window |
p |
Previous window |
f |
Find window |
, |
Rename window |
& |
Kill window |
l |
Last window |
| Pane | |
o |
Next pane |
x |
Kill pane |
! |
Break pane (send it to a new window) |
; |
Last pane |
⍽ (<Space>) |
Toggle between layout |
<prefix> q |
Show pane numbers, when the numbers show up type the key to goto that pane |
<prefix> { |
Move the current pane to the left |
<prefix> } |
Move the current pane to the right |
<prefix> z |
Toggle pane zoom |
| Buffer | |
= |
Choose buffer |
| Function | vi | emacs |
|---|---|---|
| Back to indentation | ^ |
M-m |
| Clear selection | <Escape> |
C-g |
| Copy selection | <Enter> |
M-w |
| Cursor up | k |
Up |
| Cursor down | j |
Down |
| Cursor left | h |
Left |
| Cursor right | l |
Right |
| Cursor to top line | H |
M-R |
| Cursor to bottom line | L |
|
| Cursor to middle line | M |
M-r |
| Delete entire line | d |
C-u |
| Delete to end of line | D |
C-k |
| Start of line | 0 |
C-a |
| End of line | $ |
C-e |
| Go to line | : |
g |
| Half page up | C-u |
M-Up |
| Half page down | C-d |
M-Down |
| Previous page | C-b |
Page-Up |
| Next page | C-f |
Page-Down |
| Previous word | b |
M-b |
| Next word | w |
M-f |
| Paste buffer | p |
C-y |
| Quit mode | q |
<Escape> |
| Scroll down | C-Down OR J |
C-Down |
| Scroll up | C-Up OR K |
C-Up |
| Search again | n |
n |
| Search backward | ? |
C-r |
| Search forward | / |
C-s |
| Start selection | <Space> |
C-<Space> |
| Transpose chars | C-t |
|
| Toggle Rectangle Selection | C-v |
R |