-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
192 lines (151 loc) · 5.12 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# 基本设置 {{{
#设置窗口序号从1开始
set -g base-index 1
setw -g pane-base-index 1
# 禁止重命名
set-option -g allow-rename off
# 优化nvim
set -sg escape-time 10
set-option -ga terminal-overrides ",xterm-256color:Tc"
# set-option -ga terminal-overrides ',xterm-kitty:cnorm=\E[?12h\E[?25h'
set -g default-terminal "xterm-256color"
# }}}
# 样式设置 {{{
# 消息样式
set-option -g message-style fg=#ffffff,bg=#ff6600
# 状态栏 {{{
# 状态栏刷新时间(秒)
set -g status-interval 1
# 删除窗口时重新编号
set -g renumber-windows
# 状态栏位置
set -g status-position bottom
# 定义分隔符
statusline_left_sep=''
statusline_left_alt_sep=''
statusline_right_sep=''
statusline_right_alt_sep=''
# 状态栏格式 https://man7.org/linux/man-pages/man1/tmux.1.html#FORMATS
# # 状态栏样式1 {{{
#
# # 定义颜色
# statusline_style_1_color_1='#dddddd'
# statusline_style_1_color_2='#3b4252'
# statusline_style_1_color_3='#0044BB'
#
# # 状态栏左侧字符
# set -g status-left ""
# # 状态栏前景色
# set -g status-fg $statusline_style_1_color_1
# # 状态栏背景色
# set -g status-bg $statusline_style_1_color_2
#
# # 状态栏窗口分隔符
# set -wg window-status-separator ""
#
# # 状态栏右侧宽度
# set -g status-right-length 40
#
# # 状态栏默认窗口样式
# set-window-option -g window-status-format "#[fg=$statusline_style_1_color_1, bg=$statusline_style_1_color_2] #I.#W #[fg=$statusline_style_1_color_2 bg=$statusline_style_1_color_2]$statusline_sep"
# # 状态栏当前窗口样式
# set-window-option -g window-status-current-format "#[fg=$statusline_style_1_color_1, bg=$statusline_style_1_color_3] #I.#W #[fg=$statusline_style_1_color_3 bg=$statusline_style_1_color_2]$statusline_left_sep"
#
# # 状态栏右侧样式
# set -g status-right "#[fg=$statusline_style_1_color_1]$statusline_right_alt_sep %H:%M:%S $statusline_right_alt_sep #h"
#
# # }}}
# 状态栏样式2 {{{
# 定义颜色
statusline_style_2_color_1='#dddddd'
statusline_style_2_color_2='#ff6600'
statusline_style_2_color_3='#999999'
statusline_style_2_color_4='#666666'
statusline_style_2_color_5='#3b4252'
# 状态栏左侧字符
set -g status-left ""
# 状态栏前景色
set -g status-fg $statusline_style_2_color_1
# 状态栏背景色
set -g status-bg $statusline_style_2_color_5
# 状态栏窗口分隔符
set -wg window-status-separator ""
# 状态栏右侧宽度
set -g status-right-length 40
# 状态栏默认窗口样式
set-window-option -g window-status-format "#{?window_last_flag,#[fg=$statusline_style_2_color_1],#[fg=$statusline_style_2_color_3]} #I.#W #[fg=$statusline_style_2_color_4]$statusline_left_alt_sep"
# 状态栏当前窗口样式
set-window-option -g window-status-current-format "#[fg=$statusline_style_2_color_2] #I.#W #[fg=$statusline_style_2_color_4]$statusline_left_alt_sep"
# 状态栏右侧样式
set -g status-right "#[fg=$statusline_style_2_color_4]$statusline_right_alt_sep #S "
# }}}
# }}}
# }}}
# 快捷键 {{{
#修改前缀按键
unbind C-b
set -g prefix M-a
#设置按键绑定为vi模式
setw -g mode-keys vi
# 复制模式
bind -T copy-mode-vi v send-keys -X begin-selection # 按 v 进入选择模式
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel # 按 y 复制选中文本
# 切换上一个窗口
bind M-a last-window
# 分割面板
unbind '"'
bind - splitw -v #水平分割
unbind '%'
bind | splitw -h #垂直分割
# 切换面板
unbind l
bind j select-pane -D
bind k select-pane -U
bind h select-pane -L
bind l select-pane -R
# 调整面板大小
bind M-j resizep -D 2
bind M-k resizep -U 2
bind M-h resizep -L 2
bind M-l resizep -R 2
# 交换面板
bind M-u swapp -U
bind M-d swapp -D
# 切换窗口
bind-key -n 'M-H' 'prev' # Alt+Shift+h
bind-key -n 'M-L' 'next' # Alt+Shift+l
# 分屏保留当前面板路径
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# fix key map
bind-key -n 'M-h' 'send-keys M-h'
bind-key -n 'M-j' 'send-keys M-j'
bind-key -n 'M-k' 'send-keys M-k'
bind-key -n 'M-l' 'send-keys M-l'
#鼠标设置
set -g mouse on
#命令行
bind : command-prompt
#重新载入配置文件
bind r source ~/.tmux.conf \; display "配置已重新载入"
# }}}
# 插件 {{{
set -g @plugin 'tmux-plugins/tpm' #插件管理 <prefix>+I:安装插件 <prefix>+U:更新插件 <prefix>+alt+u:卸载插件
set -g @plugin 'tmux-plugins/tmux-sensible' #tmux默认配置
set -g @plugin 'wfxr/tmux-fzf-url' #<prefix>+u: 列出所有URL,按下回车就会在默认浏览器打开
set -g @plugin 'laktak/extrakto' #<prefix>+tab: 补全
set -g @plugin 'sunaku/tmux-navigate' # tmux快捷切换窗口
set -g @plugin 'tmux-plugins/tmux-resurrect' # 会话恢复
# tmux-navigate config
set -g @navigate-left '-n M-h'
set -g @navigate-down '-n M-j'
set -g @navigate-up '-n M-k'
set -g @navigate-right '-n M-l'
set -g @navigate-back '-n M-\'
# tmux插件管理 安装插件: [<prefix>+I]
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
run '~/.tmux/plugins/tpm/tpm'
# }}}
# vim: fdm=marker