-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
67 lines (53 loc) · 2.72 KB
/
.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# C-b 和 VIM 冲突,修改 Prefix 组合键为 Control-Z,按键距离近
set -g prefix C-space
# 从tmux v1.6版起,支持设置第二个指令前缀,使用 ` 作为第二指令前缀
# set-option -g prefix2 `
set -g default-terminal "tmux-256color"
set -g base-index 1 # 窗口编号从 1 开始计数
set -g pane-base-index 1 # 窗格编号从 1 开始计数
set -g display-panes-time 10000 # PREFIX-Q 显示编号的驻留时长,单位 ms
# Status bar
set -g status-bg black
set -g status-fg white
set-option -g status-justify left
set-option -g status-left '#[fg=pink,bold][#{session_name}]'
set-option -g status-right ''
set-window-option -g window-status-current-style fg='#333333',bg="#999999"
set -wg window-status-format " #I #W "
set -wg window-status-current-format " #I:#W#F "
set -wg window-status-separator "|"
set-option -g mouse on # (Tmux v2.1) 支持鼠标: 选取文本、调整面板大小、选中并切换面板
set -g renumber-windows on # 关掉某个窗口后,编号重排
setw -g allow-rename off # 禁止活动进程修改窗口名
setw -g automatic-rename off # 禁止自动命名新窗口
# panel
set-option -g display-panes-active-colour blue
set-option -g display-panes-colour brightred
bind + resize-pane -Z # zoom
set -s set-clipboard on
# set -g allow-passthrough on
# 开启vi风格后,支持vi的C-d、C-u、hjkl等快捷键
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
# 绑定 Escape 进入 复制 模式
# bind Escape copy-mode
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l