-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtmux.conf
351 lines (311 loc) · 13.9 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# for tmux 3.1
#############
# general #
#############
set -g base-index 1
set -g renumber-windows on
set -g mouse on
set -g history-limit 50000
set -g display-time 4000
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
set -g set-clipboard on
set -g set-titles on
set -g focus-events on
###########
# theme #
###########
# style
tmux_color="#{?client_prefix,yellow,#{?pane_in_mode,blue,#{?pane_synchronized,magenta,green}}}"
tmux_style="#[default,fg=${tmux_color},reverse]"
# separators
tmux_lmain1="#{?USE_POWERLINE,,}"
tmux_lmain2="#{?USE_POWERLINE,, }"
tmux_lsub="#{?USE_POWERLINE,,|}"
tmux_rmain="#{?USE_POWERLINE,,}"
tmux_rsub="#{?USE_POWERLINE,,|}"
# segments
tmux_rbegin="${tmux_style}#[noreverse]${tmux_rmain}#[reverse] "
tmux_sbegin="${tmux_style}${tmux_lmain1} "
tmux_send=" #[noreverse]${tmux_lmain1}"
tmux_mode="#{?pane_in_mode,copy,#{client_key_table}}"
tmux_window="#W#{?window_flags,#{window_flags},}"
tmux_host="#{?#{==:#{SSH_CONNECTION},},,#{?USE_POWERLINE, ,S:}}#{=17:host_short}"
tmux_sync="#{?pane_synchronized,sync ${tmux_rsub} ,}"
tmux_table="${tmux_mode} ${tmux_rsub} "
tmux_mode="#{?#{==:${tmux_mode},root},${tmux_sync},${tmux_table}}"
set -g status-style "none"
set -g status-left "${tmux_style} #{=7:session_name} #[noreverse]${tmux_lmain2}"
set -g status-right "${tmux_rbegin}${tmux_mode}%H:%M %b-%d-%y ${tmux_rsub} ${tmux_host} "
set -g status-right-length 50
set -g window-status-format " #I ${tmux_lsub} ${tmux_window}"
set -g window-status-current-format "${tmux_sbegin}#I ${tmux_lsub} ${tmux_window}${tmux_send}"
set -ga update-environment "USE_POWERLINE"
set-hook -g "window-layout-changed" {
if -b "[ '#{window_panes}' -gt 1 ]" \
"set pane-border-status top" "set pane-border-status off"
}
setenv -gu tmux_color
setenv -gu tmux_style
setenv -gu tmux_lmain1
setenv -gu tmux_lmain2
setenv -gu tmux_lsub
setenv -gu tmux_rmain
setenv -gu tmux_rsub
setenv -gu tmux_rbegin
setenv -gu tmux_sbegin
setenv -gu tmux_send
setenv -gu tmux_mode
setenv -gu tmux_window
setenv -gu tmux_host
setenv -gu tmux_sync
setenv -gu tmux_table
setenv -gu tmux_mode
#################
# keybindings #
#################
# prefix
set -g prefix C-z
unbind -a -T prefix
bind -N "Send the prefix key" C-z send-prefix
# vi bindings
set -g mode-keys vi
set -g status-keys vi
# Don't wait after escape key input, since it slows down mode-switching in vim.
set -g escape-time 0
# mouse
bind -n MouseDrag1Status swap-window -d -t=
bind -n WheelUpPane if -Ft= "#{||:#{mouse_any_flag},#{pane_in_mode}}" \
"select-pane -t=; send -M" \
"if -Ft= '#{alternate_on}' 'select-pane -t=; send -t= Up' 'select-pane -t=; copy-mode -e; send -M'"
bind -n WheelDownPane if -Ft= "#{||:#{?alternate_on,#{mouse_any_flag},1},#{pane_in_mode}}" \
"select-pane -t=; send -M" \
"select-pane -t=; send -t= Down"
#################
# prefix mode #
#################
bind -N "Select the pane above" k select-pane -U \; switch-client -T prefix
bind -N "Select the pane below" j select-pane -D \; switch-client -T prefix
bind -N "Select the left pane" h select-pane -L \; switch-client -T prefix
bind -N "Select the right pane" l select-pane -R \; switch-client -T prefix
bind -N "Resize pane up" K resize-pane -U \; switch-client -T prefix
bind -N "Resize pane down" J resize-pane -D \; switch-client -T prefix
bind -N "Resize pane left" H resize-pane -L \; switch-client -T prefix
bind -N "Resize pane right" L resize-pane -R \; switch-client -T prefix
bind -N "Scroll one page up" C-b copy-mode -ue
bind -N "Swap pane with the one above" \
C-k swap-pane -U \; switch-client -T prefix
bind -N "Swap pane with the one below" \
C-j swap-pane -D \; switch-client -T prefix
bind -N "Create a new window" C-n new-window \; switch-client -T prefix
bind -N "Scroll halfpage up" C-u copy-mode -e \; send -X halfpage-up
bind -N "Scroll one line up" C-y copy-mode -e \; send -X scroll-up
bind -N "+goto: Show help with 'Prefix g ?'" g switch-client -T g
bind -N "Display pane numbers" G display-panes \; switch-client -T prefix
bind -N "Repeat last search forward" n copy-mode -e \; send -X search-again
bind -N "Repeat last search backward" N copy-mode -e \; send -X search-reverse
bind -N "Enter insert mode" \
i setw synchronize-panes off \; switch-client -T root
bind -N "+change: Show help with 'Prefix c ?'" c switch-client -T c
bind -N "+delete: Show help with 'Prefix d ?'" d switch-client -T d
bind -N "+search: Show help with 'Prefix f ?'" f switch-client -T regex
bind -N "Toggle the marked pane" m select-pane -m \; switch-client -T prefix
bind -N "Paste the most recent paste buffer" \
p paste-buffer \; switch-client -T prefix
bind -N "+toggle: Show help with 'Prefix t ?'" t switch-client -T t
bind -N "Kill the active pane" \
x confirm-before -p "kill-pane #P? (y/n)" kill-pane \; switch-client -T prefix
bind -N "Enter copy mode. Press 'K' in copy mode to show help." \
y copy-mode
bind -N "Enter insert mode and sync input with all visible panes" \
I setw synchronize-panes on \; switch-client -T root
bind -N "Show clock" T clock-mode \; switch-client -T prefix
bind -N "Kill current window" \
X confirm-before -p "kill-window #W? (y/n)" kill-window \;\
switch-client -T prefix
bind -N "+client: Show help with 'Prefix Z ?'" Z switch-client -T Z
bind -N "+prev: Show help with 'Prefix [ ?'" [ switch-client -T lbracket
bind -N "+next: Show help with 'Prefix ] ?'" ] switch-client -T rbracket
bind -N "Switch to the last client" C-6 switch-client -l
bind -N "Display window information" \
C-g display-message \; switch-client -T prefix
bind -N "Redraw the current client" \
C-l refresh-client \; switch-client -T prefix
bind -N "Move to the previously active pane" \
C-o if '[ #{window_panes} -gt 1 ]' last-pane last-window \;\
switch-client -T prefix
bind -N "+pane: Show help with 'Prefix C-w ?'" C-w switch-client -T ctrl-w
bind -N "+buffer: Show help with 'Prefix \" ?'" '"' switch-client -T buffer
bind -N "Prompt for window index to select" \
"'" command-prompt -p index "select-window -t ':%%'"
bind -N "Alternative prefix key, for nested clients" . send-prefix
bind -N "Search forward" / copy-mode \; command-prompt -ip "(search up)" \
-I"#{pane_search_string}" "send -X search-backward-incremental \"%%%\""
bind -N "Prompt for a command" : command-prompt \; switch-client -T prefix
bind -N "Show help. For more detailed help, run ':list-keys' instead." \
? list-keys -aN
bind -N "Zoom the active pane" Enter resize-pane -Z \; switch-client -T prefix
bind -N "Select next layout" Space next-layout \; switch-client -T prefix
bind Any switch-client -T prefix
###############
# copy mode #
###############
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi K list-keys -aNT copy-mode-vi
bind -T copy-mode-vi / command-prompt -ip "(search up)" \
-I"#{pane_search_string}" "send -X search-backward-incremental \"%%%\""
bind -T copy-mode-vi ? command-prompt -ip "(search down)" \
-I"#{pane_search_string}" "send -X search-forward-incremental \"%%%\""
bind -T copy-mode-vi C-v send -X begin-selection \;\
send -X rectangle-toggle
############
# c mode #
############
bind -T c -N "Rename current session" \
s command-prompt -I "#S" "rename-session '%%'" \; switch-client -T prefix
bind -T c -N "Rename current window" \
w command-prompt -I "#W" "rename-window '%%'" \; switch-client -T prefix
bind -T c -N "Show help" ? list-keys -aNT c
bind -T c Any switch-client -T prefix
############
# d mode #
############
bind -T d -N "Delete the most recent paste buffer" \
b delete-buffer \; switch-client -T prefix
bind -T d -N "Clear the marked pane" \
m select-pane -M \; switch-client -T prefix
bind -T d -N "Show help" ? list-keys -aNT d
bind -T d Any switch-client -T prefix
############
# g mode #
############
bind -T g -N "Select window 0" 0 select-window -t :0 \; switch-client -T prefix
bind -T g -N "Select window 1" 1 select-window -t :1 \; switch-client -T prefix
bind -T g -N "Select window 2" 2 select-window -t :2 \; switch-client -T prefix
bind -T g -N "Select window 3" 3 select-window -t :3 \; switch-client -T prefix
bind -T g -N "Select window 4" 4 select-window -t :4 \; switch-client -T prefix
bind -T g -N "Select window 5" 5 select-window -t :5 \; switch-client -T prefix
bind -T g -N "Select window 6" 6 select-window -t :6 \; switch-client -T prefix
bind -T g -N "Select window 7" 7 select-window -t :7 \; switch-client -T prefix
bind -T g -N "Select window 8" 8 select-window -t :8 \; switch-client -T prefix
bind -T g -N "Select window 9" 9 select-window -t :9 \; switch-client -T prefix
bind -T g -N "Show session/window/pane tree" b choose-tree -Z
bind -T g -N "Scroll to top" g copy-mode -e \; send -X history-top
bind -T g -N "Select the next window" \
t next-window \; switch-client -T prefix
bind -T g -N "Select the previous window" \
T previous-window \; switch-client -T prefix
bind -T g -N "Show help" ? list-keys -aNT g
bind -T g Any switch-client -T prefix
############
# t mode #
############
bind -T t -N "Toggle activity monitor" \
a setw monitor-activity \;\
display-message 'monitor-activity #{?monitor-activity,on,off}' \;\
switch-client -T prefix
bind -T t -N "Toggle activity monitor" \
b setw monitor-bell \;\
display-message 'monitor-bell #{?monitor-bell,on,off}' \;\
switch-client -T prefix
bind -T t -N "Show help" ? list-keys -aNT t
bind -T t Any switch-client -T prefix
############
# Z mode #
############
bind -T Z -N "Choose client from list" C choose-client -Z
bind -T Z -N "Suspend the current client" Q suspend-client
bind -T Z -N "Detach the current client" Z detach-client
bind -T Z -N "Show help" ? list-keys -aNT Z
bind -T Z Any switch-client -T prefix
#################
# buffer mode #
#################
bind -T buffer -N "Choose a paste buffer from a list" p choose-buffer -Z
bind -T buffer -N "Choose a paste buffer from a list and copy to clipboard" \
+ choose-buffer -Z { run "tmux show-buffer -b '%%' | xclip -i -sel clip" }
bind -T buffer -N "Show help" ? list-keys -aNT buffer
bind -T buffer Any switch-client -T prefix
###################
# lbracket mode #
###################
bind -T lbracket -N "Select the previous window with an alert" \
a previous-window -a \; switch-client -T prefix
bind -T lbracket -N "Switch to previous client" \
s switch-client -p \; switch-client -T prefix
bind -T lbracket -N "Show help" ? list-keys -aNT lbracket
bind -T lbracket Any switch-client -T prefix
###################
# rbracket mode #
###################
bind -T rbracket -N "Select the next window with an alert" \
a next-window -a \; switch-client -T prefix
bind -T rbracket -N "Switch to next client" \
s switch-client -n \; switch-client -T prefix
bind -T rbracket -N "Show help" ? list-keys -aNT rbracket
bind -T rbracket Any switch-client -T prefix
#################
# ctrl-w mode #
#################
bind -T ctrl-w -N "Resize pane up by 5" \
K resize-pane -U 5 \; switch-client -T prefix
bind -T ctrl-w -N "Resize pane down by 5" \
J resize-pane -D 5 \; switch-client -T prefix
bind -T ctrl-w -N "Resize pane left by 5" \
H resize-pane -L 5 \; switch-client -T prefix
bind -T ctrl-w -N "Resize pane right by 5" \
L resize-pane -R 5 \; switch-client -T prefix
bind -T ctrl-w -N "Close all other pane in current window" \
o confirm-before -p "kill panes? (y/n)" "kill-pane -a" \;\
switch-client -T prefix
bind -T ctrl-w -N "Rotate through the panes" \
r rotate-window \; switch-client -T prefix
bind -T ctrl-w -N "Split window horizontally" \
s split-window -v -c "#{pane_current_path}" \;\
switch-client -T prefix
bind -T ctrl-w -N "Split window vertically" \
v split-window -h -c "#{pane_current_path}" \;\
switch-client -T prefix
bind -T ctrl-w -N "Select the next window" \
w select-pane -t :.+ \; switch-client -T prefix
bind -T ctrl-w -N "Rotate through the panes in reverse" \
R rotate-window -D \; switch-client -T prefix
bind -T ctrl-w -N "Break pane to a new window" \
T break-pane \; switch-client -T prefix
bind -T ctrl-w -N "Close all other pane in current window" \
C-o confirm-before -p "kill panes? (y/n)" "kill-pane -a" \;\
switch-client -T prefix
bind -T ctrl-w -N "Rotate through the panes" \
C-r rotate-window \; switch-client -T prefix
bind -T ctrl-w -N "Split window horizontally" \
C-s split-window -v -c "#{pane_current_path}" \; switch-client -T prefix
bind -T ctrl-w -N "Split window vertically" \
C-v split-window -h -c "#{pane_current_path}" \; switch-client -T prefix
bind -T ctrl-w -N "Select the next window" \
C-w select-pane -t :.+ \; switch-client -T prefix
bind -T ctrl-w -N "Search for a pane" / command-prompt "find-window -Z -- '%%'"
bind -T ctrl-w -N "Spread panes out evenly" \
= select-layout -E \; switch-client -T prefix
bind -T ctrl-w -N "Show help" ? list-keys -aNT ctrl-w
bind -T ctrl-w Any switch-client -T prefix
#######################
# regex search mode #
#######################
bind -T regex -N "Search urls" u copy-mode -e \; send -X search-backward \
'(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*'
bind -T regex -N "Search files" f copy-mode -e \; send -X search-backward \
'(^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*'
bind -T regex -N "Search hashes" '#' copy-mode -e \; send -X search-backward \
'([0-9a-f]{7,40}|[[:alnum:]]{52}|[0-9a-f]{64})'
bind -T regex -N "Search digits" 1 copy-mode -e \; send -X search-backward \
'[[:digit:]]+'
bind -T regex -N "Search ipv4" 4 copy-mode -e \; send -X search-backward \
'[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'
bind -T regex -N "Backwards regex search" \
/ command-prompt -p "(regex search up)" \
-I"#{pane_search_string}" "copy-mode; send -X search-backward \"%%%\""
bind -T regex -N "Backwards regex search" \
? command-prompt -p "(regex search down)" \
-I"#{pane_search_string}" "copy-mode; send -X search-forward \"%%%\""
bind -T regex -N "Show help" ? list-keys -aNT regex
bind -T regex Any switch-client -T prefix