安裝

apt-get install tmux

修改 ~/.tmux.conf,設定快捷鍵

~/.tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
setw -g mode-keys vi
set -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
unbind C-b
set -g prefix C-a
bind s split-window -v
bind v split-window -h
bind-key -n C-d kill-pane
unbind-key M-up ; bind-key -n M-k select-pane -U
unbind-key M-down ; bind-key -n M-j select-pane -D
unbind-key M-Left ; bind-key -n M-h select-pane -L
unbind-key M-right ; bind-key -n M-l select-pane -R
unbind-key C-Up; bind-key -n C-k resize-pane -U
unbind-key C-Down; bind-key -n C-j resize-pane -D
unbind-key C-Left; bind-key -n C-h resize-pane -L
unbind-key C-Right; bind-key -n C-l resize-pane -R
set -g pane-active-border-fg red
set -g pane-border-fg black
set -g status-justify left
set -g status-interval 120 # 120 sec refresh status
set -g display-time 3000
set -g status-bg black
set -g status-fg white
set-window-option -g window-status-current-fg blue
set-window-option -g window-status-current-bg yellow
set-window-option -g window-status-current-attr default

dev-tmux.sh

1
2
3
4
5
tmux new-session -d 'vim'
tmux split-window -h 'ipython'
tmux split-window -v
tmux new-window 'mutt'
tmux -2 attach-session -d

some key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tmux kill-session -t [session name] : delete特定session
tmux kill-session -a : delete all session
tmux ls : 列出session
tmux attach -t [session name] : attach到特定session
C-a+[ : 進入copy mode
C-a + C-j, C-k, C-l, C-h : Resize pane
Alt-j, Alt-k, Alt-l, Alt-h : 移動到pane
C-a+n, p : 移動到window
C-a+l : 兩window中移動
C-a+c : create window
C-d : kill pane
C-a+s : 垂直分割
C-a+v : 水平分割
C-a+? : 快捷鍵說明