-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path.tmux.conf.erb
452 lines (379 loc) · 17.6 KB
/
.tmux.conf.erb
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# Dynamic configuration file generated by ~/Makefile from <%= __FILE__ %>
#
# DO NOT EDIT THIS FILE BY HAND --
# YOUR CHANGES WILL BE OVERWRITTEN
#
<% tmux_version = `tmux -V`.split.last %>
<%
# Enthium layout - https://github.com/sunaku/enthium
navigate_back = 'v'
navigate_left = 'h'
navigate_up = 't'
navigate_down = 'n'
navigate_right = 's'
## Engram 2.0 layout - https://engram.dev
#navigate_back = '.'
#navigate_left = 'h'
#navigate_up = 't'
#navigate_down = 's'
#navigate_right = 'n'
## Dvorak layout
#navigate_back = 'd'
#navigate_left = 'h'
#navigate_up = 't'
#navigate_down = 'n'
#navigate_right = 's'
## Qwerty layout
#navigate_back = '\\'
#navigate_left = 'h'
#navigate_up = 'k'
#navigate_down = 'j'
#navigate_right = 'l'
%>
bind-key R source ~/.tmux.conf \; display-message 'config reloaded!'
#-----------------------------------------------------------------------------
# terminal
#-----------------------------------------------------------------------------
# enable mouse support for general selection and control
set-option -g mouse on
# auto-set terminal title to current window pane's title
set-option -g set-titles on
# enable 256-color support for pretty colorschemes in Vim
# or if using KiTTY, enable its enhanced terminal profile
if-shell 'test "$TERM" = "xterm-kitty"' \
'set-option -g default-terminal "xterm-kitty"' \
'set-option -g default-terminal "screen-256color"'
# allow Vim to receive focus events from terminal window
set-option -g focus-events on
# allow Vim to recieve modifier keys: Shift, Control, Alt
set-window-option -g xterm-keys on
# prevent tmux from catching modifier keys meant for Vim
# (set > 0: https://github.com/microsoft/WSL/issues/5931)
set-option -s escape-time 1
# enable 24-bit true color RGB escape sequences under st
# https://sunaku.github.io/tmux-24bit-color.html
set-option -ga terminal-overrides ',st-256color:Tc'
set-option -ga terminal-overrides ',xterm-256color:Tc' # hterm (ChromeOS)
# allow set-titles to change the window title under XTerm
# http://opennomad.com/content/goodbye-screen-hello-tmux
set-option -ga terminal-overrides ',xterm*:XT'
# allow set-titles to change the window title under XTerm
# http://opennomad.com/content/goodbye-screen-hello-tmux
# http://stackoverflow.com/questions/15195624
set-option -ga terminal-overrides ',st-256color:smkx=\E='
# yank to system clipboard rather than primary selection
# http://invisible-island.net/xterm/terminfo-contents.html#tic-xterm_tmux
set-option -ga terminal-overrides ',xterm*:Ms=\E]52;c;%p2%s\007'
# KiTTY always appends to clipboard; must clear it first
# https://sw.kovidgoyal.net/kitty/protocol-extensions.html#pasting-to-clipboard
set-option -ga terminal-overrides ',xterm-kitty:Ms=\E]52;c;!\007\E]52;c;%p2%s\007'
# prevent standout from appearing as italics under URxvt
# http://comments.gmane.org/gmane.comp.terminal-emulators.tmux.user/1927
set-option -ga terminal-overrides ',rxvt-unicode*:sitm@'
<% if tmux_version >= '3.3' %>
# pass "Ptmux;" escape sequences through to the terminal
set-window-option -g allow-passthrough on
<% end %>
#-----------------------------------------------------------------------------
# appearance
#-----------------------------------------------------------------------------
# Colors from the "lucius" and "gruvbox" themes in the vim-airline plugin:
# https://github.com/bling/vim-airline/blob/master/autoload/airline/themes/lucius.vim
# https://github.com/morhetz/gruvbox/blob/master/autoload/airline/themes/gruvbox.vim
<%
colorscheme =
if ENV['THEME'] == 'light'
:PaperColor
else
:everforest
end
case colorscheme
when :lucius
# Colors from Lucius theme https://github.com/NLKNguyen/papercolor-theme
status_style = 'fg=colour238,bg=colour253' # lucius normal airline_c
window_status_current_style = 'fg=colour231,bg=colour67' # lucius visual airline_a
pane_border_style = 'fg=colour253' # lucius normal airline_c
pane_active_border_style = 'fg=colour204'
status_ruler_style = 'fg=colour231,bg=colour244'
status_login_style = 'fg=colour231,bg=colour204'
when :PaperColor
# Colors from PaperColor theme https://github.com/NLKNguyen/papercolor-theme
status_style = 'fg=colour238,bg=colour254' # PaperColor TabLineSel
window_status_current_style = 'fg=colour255,bg=colour31' # PaperColor TabLine
pane_border_style = 'fg=colour252' # PaperColor StatusLineNC
status_ruler_style = 'fg=colour255,bg=colour31' # PaperColor TabLine
when :everforest
# Colors from everforest theme https://github.com/sainnhe/everforest
status_style = 'fg=#868d80,bg=#374247' # everforest StatusLine
window_status_current_style = 'fg=#999f93,bg=#4a555b' # everforest TabLine
window_status_current_style = 'fg=#2f383e,bg=#a7c080' # everforest TabLineSel
window_status_current_style = 'bg=#2f383e,fg=#a7c080' # everforest TabLineSel (reverse)
pane_border_style = 'fg=#4a555b' # everforest TabLine
pane_active_border_style = 'fg=#7fbbb3' # everforest Blue
status_ruler_style = window_status_current_style
status_login_style = window_status_current_style + ',bold,reverse'
when :gruvbox_material
# Colors from gruvbox-material theme https://github.com/sainnhe/gruvbox-material
status_style = 'fg=colour246,bg=colour237' # gruvbox normal airline_c
window_status_current_style = 'fg=colour214,bg=colour239' # gruvbox bright_yellow dark2
pane_border_style = 'fg=colour239' # gruvbox normal airline_b
pane_active_border_style = 'fg=colour208' # gruvbox visual airline_c
status_ruler_style = window_status_current_style
status_login_style = window_status_current_style + ',bold,reverse'
end
%>
set-option -g status-style <%= status_style %>
set-window-option -g window-status-current-style <%= window_status_current_style %>
set-option -g pane-border-style <%= pane_border_style %>
set-option -g pane-active-border-style <%= pane_active_border_style %>
set-option -g message-style <%= window_status_current_style %>
set-window-option -g mode-style <%= status_login_style %>
# Common UI interaction cues from Blueprint CSS:
# http://blueprintcss.org/tests/parts/forms.html
set-window-option -g window-status-bell-style 'bg=#205791,fg=#d5edf8' # info (blue)
set-window-option -g window-status-activity-style 'bg=#8a1f11,fg=#fbe3e4' # error (red)
#-----------------------------------------------------------------------------
# status bar
#-----------------------------------------------------------------------------
# toggle status bar visibility
bind-key -n M-: set-option -g status
# toggle status bar position
bind-key -n M-\; \
if-shell 'tmux show-option -g status-position | grep -q top$' \
'set-option -g status-position bottom' \
'set-option -g status-position top'
# put status bar at the top of the screen
set-option -g status-position top
# list windows on left side of status bar
set-option -g status-left ''
# make window list easier to scan
set-window-option -g window-status-format ' #[bold]#I#F#[nobold]#W '
set-window-option -g window-status-current-format ' #[bold]#I#F#[nobold]#W '
set-window-option -g window-status-separator ''
# show pane title, pane identifier, and hostname on right side of status bar
set-option -g status-right-length 64
set-option -g status-right '#{=32:pane_title} \
#[<%= status_ruler_style %>] #S:#I.#P \
#(test -n "$SSH_TTY" && echo "#[<%= status_login_style %>] #H ")'
#-----------------------------------------------------------------------------
# windows
#-----------------------------------------------------------------------------
# create window
bind-key -n M-e new-window
# rename window
bind-key -n M-E command-prompt -I '#W' 'rename-window "%%%"'
<% if tmux_version >= '2.6' %>
set-window-option -g automatic-rename off
<% end %>
# break off pane to a new window
bind-key -n M-u \
command-prompt -p 'break-pane:' -I '#W' \
'break-pane ; rename-window "%%%"'
bind-key -n M-U break-pane
# focus window
bind-key -n 'M-[' previous-window
bind-key -n 'M-]' next-window
bind-key -n M-, last-window
# focus by number
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
bind-key -n M-0 choose-window
bind-key -n M-1 select-window -t :1
bind-key -n M-2 select-window -t :2
bind-key -n M-3 select-window -t :3
bind-key -n M-4 select-window -t :4
bind-key -n M-5 select-window -t :5
bind-key -n M-6 select-window -t :6
bind-key -n M-7 select-window -t :7
bind-key -n M-8 select-window -t :8
bind-key -n M-9 select-window -t :1 \; select-window -t :-1
# swap window
<% if tmux_version >= '3.0' %>
bind-key -n 'M-{' swap-window -t :-1 \; select-window -t :-1
bind-key -n 'M-}' swap-window -t :+1 \; select-window -t :+1
<% else %>
bind-key -n 'M-{' swap-window -t :-1
bind-key -n 'M-}' swap-window -t :+1
<% end %>
# monitor window
set-option -g visual-activity on
set-option -g visual-silence on
<% if tmux_version < '2.6' %>
set-option -g bell-on-alert on
<% end %>
bind-key -n M-g \
set-window-option monitor-activity \;\
display-message 'monitor-activity #{?monitor-activity,on,off}'
bind-key -n M-G \
if-shell 'tmux show-window-option -g monitor-activity | grep -q off$' \
'set-window-option -g monitor-activity on' \
'set-window-option -g monitor-activity off' \;\
display-message 'monitor-activity #{?monitor-activity,on,off} (global)'
bind-key -n M-x \
if-shell 'tmux show-window-option -v monitor-silence | grep -q ^[^0]' \
'set-window-option monitor-silence 0' \
'set-window-option monitor-silence 60' \;\
display-message 'monitor-silence #{?monitor-silence,#{monitor-silence},off}'
bind-key -n M-X \
command-prompt -p 'monitor-silence (seconds):' -I '#{monitor-silence}' \
'set-window-option monitor-silence %% ;\
display-message "monitor-silence #{?monitor-silence,on,off}"'
#-----------------------------------------------------------------------------
# panes
#-----------------------------------------------------------------------------
# send input to all panes in window (toggle)
bind-key C-a \
set-option synchronize-panes \;\
display-message 'synchronize-panes #{?synchronize-panes,on,off}'
# clear the screen in all panes in window
bind-key C-l \
set-option synchronize-panes on \;\
send-keys C-l \;\
set-option synchronize-panes off
# create pane (below, above, left, right)
bind-key -n M-o split-window -c '#{pane_current_path}'
bind-key -n M-O split-window -c '#{pane_current_path}' -b
bind-key -n M-A split-window -c '#{pane_current_path}' -b -h
bind-key -n M-a split-window -c '#{pane_current_path}' -h
# join pane (above, left, below, right)
bind-key -n M-K move-pane -t .-1 -s . -h # join pane at right of prev pane
bind-key -n M-J move-pane -t .-1 -s . # join pane at bottom of prev pane
# resize pane
bind-key -r <%= navigate_left.upcase %> resize-pane -L 5
bind-key -r <%= navigate_up.upcase %> resize-pane -U 5
bind-key -r <%= navigate_down.upcase %> resize-pane -D 5
bind-key -r <%= navigate_right.upcase %> resize-pane -R 5
bind-key -n M-z resize-pane -y '100%'
bind-key -n M-w resize-pane -x '100%'
# find pane
bind-key -n M-f choose-tree
# zoom pane
bind-key -n M-m resize-pane -Z
bind-key -n M-M resize-pane -x '100%' -y '100%'
# swap pane
bind-key -n M-j swap-pane -D
bind-key -n M-k swap-pane -U
<%
shift = lambda do |char|
case char
when ',' then '<'
when '.' then '>'
else char.upcase
end
end
%>
bind-key -n 'M-<%= shift.(navigate_back) %>' run-shell 'tmux select-pane -l \; swap-pane -d -s #D'
bind-key -n 'M-<%= shift.(navigate_left) %>' run-shell 'tmux select-pane -L \; swap-pane -d -s #D'
bind-key -n 'M-<%= shift.(navigate_up) %>' run-shell 'tmux select-pane -U \; swap-pane -d -s #D'
bind-key -n 'M-<%= shift.(navigate_down) %>' run-shell 'tmux select-pane -D \; swap-pane -d -s #D'
bind-key -n 'M-<%= shift.(navigate_right) %>' run-shell 'tmux select-pane -R \; swap-pane -d -s #D'
# move pane to another window
bind-key -n 'M-!' join-pane -t :1
bind-key -n 'M-@' join-pane -t :2
bind-key -n 'M-#' join-pane -t :3
bind-key -n 'M-$' join-pane -t :4
bind-key -n 'M-%' join-pane -t :5
bind-key -n 'M-^' join-pane -t :6
bind-key -n 'M-&' join-pane -t :7
bind-key -n 'M-*' join-pane -t :8
bind-key -n 'M-(' run-shell 'tmux select-window -t :1 \;\
select-window -t :-1 \;\
join-pane -s "#{pane_id}"'
bind-key -n 'M-)' choose-window 'join-pane -t "%%%"'
bind-key -n M-F choose-tree 'join-pane -t "%%%"'
# promote pane (toggle)
bind-key -n M-Enter \
if-shell 'test #P -ne 1' \
'swap-pane -t 1; last-pane' \
'last-pane; swap-pane -s 1'
#-----------------------------------------------------------------------------
# layouts
#-----------------------------------------------------------------------------
bind-key -n M-V select-layout tiled
bind-key -n M-Z select-layout even-vertical
bind-key -n M-W select-layout even-horizontal
# half-screen tiling layouts (vertical, horizontal)
# https://sunaku.github.io/tmux-half-screen-tiling-layouts.html
bind-key -n M-L select-layout main-vertical \;\
run-shell 'tmux resize-pane -t 1 -x $(( #{window_width} / 2 ))'
bind-key -n M-D select-layout main-horizontal \;\
run-shell 'tmux resize-pane -t 1 -y $(( #{window_height} / 2 ))'
# binary space partitioned layouts (dwindle, spiral)
# https://sunaku.github.io/tmux-layout-dwindle.html
bind-key -n M-d run-shell 'tmux-layout-dwindle brhc && tmux-redraw-vim'
bind-key M-d run-shell 'tmux-layout-dwindle trhc && tmux-redraw-vim'
bind-key -n M-l run-shell 'tmux-layout-dwindle brvc && tmux-redraw-vim'
bind-key M-l run-shell 'tmux-layout-dwindle blvc && tmux-redraw-vim'
#-----------------------------------------------------------------------------
# scrollback buffer
#-----------------------------------------------------------------------------
# buffer length
set-option -g history-limit 9999 # NOTE: the maximum allowed limit is 32767
# search buffer using copy mode
bind-key -n M-/ copy-mode \;\
command-prompt -p 'search-backward (press up):' \
-i 'send-keys -X search-backward-incremental "%%%"'
# search buffer using Vim or less
bind-key -n M-P \
capture-pane -J -S - \; \
new-window -n '#S:#I.#P' -a ' \
tmux save-buffer - \; delete-buffer | { \
if command -v vim; \
then vim -R -c "set nofen is hls ic" -; \
else less; \
fi; \
}; \
' \; \
run-shell 'tmux send-keys G \?'
# search colored buffer using less
bind-key -n M-p \
capture-pane -e -J -S - \; \
new-window -n '#S:#I.#P' -a ' \
tmux save-buffer - \; delete-buffer | \
less -R \
' \; \
run-shell 'tmux send-keys G \?'
# scroll buffer
# NOTE: set "URxvt.saveLines: 0" in ~/.Xdefaults to make Shift+PageUp bindable
# NOTE: see http://aperiodic.net/screen/interface for doing the same in XTerm
bind-key -n S-PPage copy-mode -eu
bind-key -n S-NPage send-keys -X page-down
# copy text from buffer
bind-key -n M-c copy-mode
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi - send-keys -X jump-again
bind-key -T copy-mode-vi _ send-keys -X jump-reverse
bind-key -T copy-mode-vi ? command-prompt -p 'search-backward:' -I '#{pane_search_string}' -i 'send-keys -X search-backward-incremental "%%%"'
bind-key -T copy-mode-vi / command-prompt -p 'search-forward:' -I '#{pane_search_string}' -i 'send-keys -X search-forward-incremental "%%%"'
# transfer copied text to attached terminal with yank:
# https://github.com/sunaku/home/blob/master/bin/yank
bind-key -T copy-mode-vi Y send-keys -X copy-pipe 'yank > #{pane_tty}'
# open the visual selection with xdg-open(1)
bind-key -T copy-mode-vi O send-keys -X copy-pipe 'xargs -r xdg-open'
# paste most-recently copied text
bind-key -n M-i paste-buffer
# paste previously copied text (chosen from a menu)
bind-key -n M-I choose-buffer
# transfer most-recently copied text to attached terminal with yank:
# https://github.com/sunaku/home/blob/master/bin/yank
bind-key -n M-y run-shell 'tmux save-buffer - | yank > #{pane_tty}'
# transfer previously copied text (chosen from a menu) to attached terminal:
# https://github.com/sunaku/home/blob/master/bin/yank
bind-key -n M-Y choose-buffer 'run-shell "tmux save-buffer -b \"%%%\" - | yank > #{pane_tty}"'
#-----------------------------------------------------------------------------
# TMUX plugin manager https://github.com/tmux-plugins/tpm
#-----------------------------------------------------------------------------
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-capture-pane-contents on
set -g @plugin 'fcsonline/tmux-thumbs'
bind-key -n M-C run-shell -b ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.sh
set -g @plugin 'sunaku/tmux-navigate'
set -g @navigate-back '-n M-<%= navigate_back %>'
set -g @navigate-left '-n M-<%= navigate_left %>'
set -g @navigate-up '-n M-<%= navigate_up %>'
set -g @navigate-down '-n M-<%= navigate_down %>'
set -g @navigate-right '-n M-<%= navigate_right %>'
run-shell ~/.tmux/plugins/tpm/tpm