Tmux

Shortcuts

session:

tmux new-session -s work
tmux attach -t work
tmux attach

Detach from a session: C-b d. Rename session: C-b $.

Switch between sessions:

C-b (          previous session
C-b )          next session
C-b L          ‘last’ (previously used) session
C-b s          choose a session from a list

window:

C-b c          create a new window
C-b 1 ...      switch to window 1, ..., 9, 0
C-b p          previous window
C-b n          next window

Pane:

C-b "          split vertically (top/bottom)
C-b %          split horizontally (left/right)

Switching between panes:

C-b left       go to the next pane on the left
C-b right      (or one of these other directions)
C-b up
C-b down
C-b o          go to the next pane (cycle through all of them)
C-b ;          go to the ‘last’ (previously used) pane

Resizing panes:

C-b M-up, C-b M-down, C-b M-left, C-b M-right
               resize by 5 rows/columns
C-b C-up, C-b C-down, C-b C-left, C-b C-right
               resize by 1 row/column

Start shell with tmux

Start with tmux

[ -z "$TMUX"  ] && { tmux attach || exec tmux new-session && exit;}

Window name update (current directory)

How to automatically rename tmux windows to the current directory

# be sure to see note* below
set -g window-status-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
set -g window-status-current-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'

# status bar updates every 15s by default**, change to 1s here 
# (this step is optional - a lower latency might have negative battery/cpu usage impacts)
set -g status-interval 1