You can have multiple tmux sessions running at the same time then jump in and out (aka attach / detach) of them, switch between them, and manage them from both from the terminal and from within a session itself.
tmux | starts a new tmux session |
tmux ls | lists available sessions (aka list-sessions) |
tmux a | attaches to the most recently used session |
tmux a -t 1 | attach to session number 1 |
tmux a -t foo | attach to session with name that starts ‘foo’ |
tmux $ foo | renames the session you’re attached to to ‘foo’ |
tmux kill-session | kill the session |
ctrl + b d | detach from session |
ctrl + b w | overview of session and windows (use q to quit) |
ctrl + b ( | move to previous session |
ctrl + b ) | move to next session |
The following commands are performed while in a tmux session and require the
prefix to be used first. By default this will be ctrl + b
.
% | split pane vertically |
” | split pane horizontally |
; | previous pane |
o | next pane |
q | show pane numbers (then hit number to jump to that pane) |
ctrl + o | rotate panes (I often hit this by accident instead of next pane) |
Used while inside a session and require the prefix.
, | rename |
w | list (then select using arrows) |
n | next |
p | previous |
1 | jump to window 1 |
Change (aka swap) the order of tmux windows using the swap-window
command, it
accepts a source -s
and a destination -t
argument. Note that by default the
ordering of tmux windows will be zero based but I changed this in my tmux.conf
file.
# move window in position 3 to position 1
swap-window -s 3 -t 1
After making changes to your .tmux.conf file don’t try and source it from terminal: you need to source the file from within tmux. So just open a tmux session, hit ctrl-b then : and source the file from there. This has caught me out loads of times because terminal will show an error message making you think you’ve made an error in the config file.