tmux
Sessions
Start session
tmux new
tmux new -s mysession
Show sessions
- tmux ls
Kill sessions
tmux kill-session -t mysession
tmux kill-session -a
;kill all sessions but last session
Attach sessions
tmux a
tmux a -t #
tmux a -t mysession
Keyboard
PREFIX: CTRL+b
sessions
- Detach from session: PREFIX + d
- Rename session: PREFIX + $
- Move to previous session: PREFIX + (
- Move to next session: PREFIX + )
Windows
- Create a new window: PREFIX + c
- Rename the window: PREFIX + ,
- Move the window: PREFIX + {window-number}
- Close current window: PREFIX + &
- Move to previous window: PREFIX + p
- Move to next window: PREFIX + n
- Go to any window: PREFIX + s
Panes
- Split panes horizontally: PREFIX + "
- Split panes vertically: PREFIX + %
- Switch between panes: PREFIX + Left/Right/Up/Down
Copy Mode
- Enter copy mode: PREFIX + [
- Exit copy mode: q
Configuration
.tmux.conf
# Enable 256 color in terminal
set -g default-terminal "tmux-256color"
# Fix the dynamic title name
set-option -g allow-rename off
# set vi-mode
set-window-option -g mode-keys vi
# keybindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Window
setw -g window-status-current-style 'bg=#282a36 fg=#f8f8f2 bold'
vi-mode
- 行模式:Shift + v
- 列模式:Ctrl + v
- 取消:y
- 複製:Enter
- 貼上:PREFIX + ]
# set vi-mode
set-window-option -g mode-keys vi
# keybindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
FAQ
Window 無法固定標題名稱
Solution: ~/.tmux.conf
set-option -g allow-rename off