-
Notifications
You must be signed in to change notification settings - Fork 1
/
.tmux.conf
669 lines (518 loc) · 35 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
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# source-file ~/util/.tmux.reset.conf
# TODO: make a bind inside shared.conf that runs reset.conf. I dont want to
# auto run reset.conf all the time because it will hide any e.g. default
# bindings that are from upstream tmux or whatever.
# ^ Well after reviewing the above i dont think it was ever a good idea to clear out default
# configuration because there are a lot of nice things from there.
unbind L
bind L source-file ~/.tmux.conf
# set -g default-shell zsh
# Report that we can handle 256 colors and italic (be sure to set up terminfo)
set -g default-terminal "tmux-256color"
## Commenting out my clipboard stuff because trying to use term capabilities for that.
# just understand that on linux gui (at least 16.04), $DISPLAY needs to be set before this pbcopy
# seems to function, due to the way tmux spawns it.
# bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy" \; display-message "copied to clipboard"
# bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy" \; display-message "copied to system clipboard"
# Rebind prefix to avoid conflicts
unbind C-b
set -g prefix C-a
# this is for convenience (if user continued to hold ctrl while issuing ctrl+a, d to detach)
bind C-d detach-client
bind c new-window -a -c '#{pane_current_path}'
# # interpret alt numbers as tmux window selection (browser analogue)
# bind -n M-1
# bind -n PageUp if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{m/r:^(ssh|man|less),#{pane_current_command}}}' {send-keys PageUp} {copy-mode -eu}
bind -n S-PageUp copy-mode -eu
bind -n M-PageUp copy-mode -eu
bind -T copy-mode-vi M-PageDown send -X page-down
bind -T copy-mode-vi S-PageDown send -X page-down
# bind -n C-d if '~/util/discriminator "#{s/\"/\\\"/:pane_title}" "#{pane_current_command}" "#{pane_pid}" C-d "#{window_panes}" "#{window_zoomed_flag}"' {send-keys C-d} {confirm-before -p "send Ctrl+D? (y/n)" "send-keys C-d"}
bind -n C-d if -F '#{m/r:(z|ba|s)sh,#{pane_current_command}}' {confirm-before -p "send Ctrl+D? (y/n)" "send-keys C-d"} {send-keys C-d}
# titles string affects tmux based testing which uses pane titles to identify a dedicated pane.
# Since I wasn't using it to show something important in the body of the title, i want to leave it
# settable (and allow for its total settability). So we don't want to actually use
# set-titles-string.
set -g set-titles off
# set -g set-titles-string 'tmux session #{session_name} [#{pane_title}] #{pane_current_path}'
# the convention I use is the new one used by Tmux 2:
# F1-F12 are F1 to F12
# F13-F24 are S-F1 to S-F12
# F25-F36 are C-F1 to C-F12
# F37-F48 are C-S-F1 to C-S-F12
# F49-F60 are M-F1 to M-F12
# F61-F64 are M-S-F1 to M-S-F3
# Except that since that also does not support M-S-F10 or M-C-*, I will
# appropriate F61-63 for them.
# ungodly stuff that took forever to track down
## This one is the "old" way to set 24 bit color and xterm-title.
## set -sa terminal-overrides "*:Tc:XT"
# set using new term features feature of tmux 3.2+
set -sa terminal-features "*:hyperlinks:strikethrough:RGB:title:ccolour:cstyle:clipboard"
# To give tmux awareness of undercurl and underline color, refer to
# https://github.com/alacritty/alacritty/issues/1628
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
# Using new clearer semantics to define my F10/capslock shenanigans
# there can be more, but these 5 are implemented in my putty, and any other
# combos are RSI-inducing anyway.
# these are all for F10
set -s user-keys[0] "\e[21~"
set -s user-keys[1] "\e[21;2~" # shift
# set -s user-keys[2] "\e[21;3~" # alt/cmd
# So it seems like i dont need to be definign these as user keys when my escapes im using are standard modifiers on f10
set -s user-keys[3] "\e[21;5~" # ctrl
# set -s user-keys[4] "\e[21;4~" # shift+alt/cmd
set -s user-keys[5] "\e[21;6~" # shift+ctrl
# escape-newline sequence. could out of the box be alt-enter but i'm using it with shift-enter with alacritty
set -s user-keys[6] "\e\n"
# These specify my ad hoc escape seqs for next and prev tab semantics (bound to ctrl(+shift)+tab or cmd+shift+] and cmd+shift+[)
set -s user-keys[7] "\e[Y"
set -s user-keys[8] "\e[2Y"
# Makes this F10 a truly context-sensitive multipurpose switching key
# Here's what it does, (it runs the first one in the list that matches the situation)
# 1. Presses ESC if in vim and not in normal mode
# 2. Switches to next tmux pane
# 3. Switches to next Vim window with Tab key (if there is only one tmux pane in the tmux window) (note that this function is elaborately configured inside of Vim to smoothly step through windows and tabs)
# 4. Sends F10 as passthrough (if only one tmux pane in window and it is not running vim)
# this is somehow needed to make tmux parrot C-Tab/C-S-Tab back out
bind -n C-Tab send-keys "\e[27;5;9~"
bind -n C-S-Tab send-keys "\e[27;6;9~"
bind O select-pane -t :.-
# TODO TODO simplify these clauses into a pattern for multiple commands checked against the command
# rather than relying on the pretty unmaintainable logical ops
bind -n User0 if -F '#{m/r:AIDER,#{pane_title}}' "send-keys Escape" {if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},docker}}}' "send-keys F10" "selectp -t :.+"}
bind User0 if -F '#{m/r:AIDER,#{pane_title}}' "send-keys Escape" {if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},docker}}}' "selectp -t :.+" "send-keys F10"}
bind -T copy-mode-vi User0 select-pane -t :.+
# I am actually unsure about what I want to do here. I see the value in having
# a dedicated bind capslock-bind for a second-level window switcher (so that
# F1/2 won't tunnel through to cycle a potential third tmux level's window) but
# I'm not sure whether it's better to go up from the bottom or down from the
# top... perhaps it's best to have both a max-tunneling bind (F1/2) and
# a lax-tunneling bind (or a ssh-boundary bind or a tmux-boundary bind... hmm).
bind -n User1 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys S-F10" "select-pane -t :.-"
bind User1 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "select-pane -t :.-" "send-keys S-F10"
bind -T copy-mode-vi User1 select-pane -t :.-
bind -n User3 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys C-F10" "last-pane"
bind User3 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "last-pane" "send-keys C-F10"
# Eventually I realized I don't want contextual with the window cycling. I usually want to cycle the outermost windows.
bind -n M-F10 next-window
bind M-F10 "send-keys M-F10"
bind -n M-S-F10 previous-window
bind M-S-F10 "send-keys M-S-F10"
# # This causes a zoomed or single pane with ssh inside to tunnel.
# bind -n M-F10 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys M-F10" next-window
# bind M-F10 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' next-window "send-keys M-F10"
# bind -n M-S-F10 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys M-S-F10" previous-window
# bind M-S-F10 if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' previous-window "send-keys M-S-F10"
bind -n User6 send-keys "\033\n"
# Esc [ Y is not understood by nvim and there is as of yet still no way to inform nvim of it. So I start to cannibalize
# high complexity modifier F keys (tmux lost F13 onward replacing them with M-C-F1 etc, curiously it all magically
# works and are recognized by nvim) so I will use M-C-F11 for this key pair.
bind -n User7 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:1,#{session_windows}}}' 'send-keys M-C-S-F11' previous-window
bind -n User8 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:1,#{session_windows}}}' 'send-keys M-C-F11' next-window
bind User7 send-keys M-C-S-F11
bind User8 send-keys M-C-F11
bind -n C-h if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "send-keys C-h" "select-pane -L"
bind -r C-h if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "select-pane -L" "send-keys C-h"
bind -n C-j if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "send-keys C-j" "select-pane -D"
bind -r C-j if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "select-pane -D" "send-keys C-j"
bind -n C-k if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "send-keys C-k" "select-pane -U"
bind -r C-k if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "select-pane -U" "send-keys C-k"
bind -n C-l if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "send-keys C-l" "select-pane -R"
bind -r C-l if -F '#{||:#{==:1,#{window_panes}},#{||:#{m/r:^N?VIM,#{pane_title}},#{&&:#{window_zoomed_flag},#{==:ssh,#{pane_current_command}}}}}' "select-pane -R" "send-keys C-l"
bind -T copy-mode-vi C-h select-pane -L
bind -T copy-mode-vi C-j select-pane -D
bind -T copy-mode-vi C-k select-pane -U
bind -T copy-mode-vi C-l select-pane -R
# I hope this is a good idea (can't use shift because terminals don't
# distinguish shift for ctrl keys...)
bind -n M-C-h send-keys C-h
bind -n M-C-j send-keys C-j
bind -n M-C-k send-keys C-k
bind -n M-C-l send-keys C-l
# more of that overloaded good stuff
bind -n C-_ if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},docker}}}' {send-keys C-_} {split-window -c '#{pane_current_path}'}
bind -n 'C-\' if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},docker}}}' {send-keys C-\\} {split-window -h -c '#{pane_current_path}'}
#### i've disabled the tmux side ephemeral pane creation because i've found that it is disruptive to the vim pane when i
#### am in a zoomed vim and do this. it's a case that tmux cannot handle well at all to temporarily turn a zoomed pane
#### into a two pane, you are either zoomed or not zoomed (with the clutter of other panes fully reintroduced!)
#### In light of this, I'm divesting this branch of capability under neovim instead of tmux which seems fairly sound.
# # I have established a convention around having key combos for launching oft-used commands without shell so their panes
# # close once done. First I made it split running git diff or git log -p based on contextually whether the repo is clean.
# #
# # I am planning to make further evolutions on it:
# # - Do new windows instead of splits. Pollution of windowlist is not a concern as all of these are ephemeral, and
# # defaulting to fullscreen is something I really want to do more of.
# # - Alternately, though, even this should be contextual! If pane is zoomed, we can do a new window. Otherwise do a
# # split.
# # A list of ideas for UXs follows:
# # - (initial one that spearheaded this) Cmd+D: contextual git diff or git log -p if git is clean
# # - Repeated ones launch with sift-provided diffs.
# # - (also initial) Cmd+Shift+D: ditto as above but vsplit (i never use it)
# # - (also initial) Cmd+C: git commit-push writing commit message in nvim
# # - A dedicated key for launching a diff against past. so it's quite like the above but stacking will show diff against
# # the next commit, which is ergonomic. I think stacking may work fine as a way to hop back when we go past.
# # - I need to think about how stacking is supposed to work though. For windows, they will consume too much windowbar
# # real estate. Perhaps on any ephemeral window I would do split basedstacks, and could even default to zooming in.
# # - A new key can perhaps be used to nuke the whole stack.
# # - With this, I split out the `git log -p` into a separate key to open just that, and keep doing sift upon stacking.
#
# # An overall property that is really great about this is as i design more and more instantly accessible commands to
# # launch ephemerally, it reduces the desire to keep terminals open just to fiddle on stuff like this.
#
# ### This is cool, shows i can detect a second invocation on top, good building block.
# bind -n M-d if "git -C #{pane_current_path} diff-index --quiet HEAD --" {
# if -F '#{==:#{pane_start_command},git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT log -p}' {
# split-window -l "95%" -c '#{pane_current_path}' bash -c "GIT_EXTERNAL_DIFF=sift GIT_PAGER=less git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT log -p --ext-diff --pretty=format:'%C(bold yellow)%H%Creset%C(auto)%d%Creset %s %Cgreen%ci %C(yellow)(%cr) %C(bold blue)<%an>%Creset'"
# } {
# split-window -l "85%" -c '#{pane_current_path}' git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT log -p
# }
# } {
# if -F '#{==:#{pane_start_command},git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT diff}' {
# split-window -l "95%" -c '#{pane_current_path}' bash -c "GIT_EXTERNAL_DIFF=sift GIT_PAGER=less git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT diff --ext-diff"
# } {
# split-window -l "75%" -c '#{pane_current_path}' git --config-env=delta.hyperlinks-file-link-format=GIT_DELTA_HYPERLINK_FORMAT diff
# }
# }
#
# # TODO bring it to parity
# bind -n M-D if "git -C #{pane_current_path} diff-index --quiet HEAD --" {if -F '#{m:git log -p,#{pane_start_command}}' {split-window -l "95%" -c '#{pane_current_path}' bash -c "GIT_EXTERNAL_DIFF=sift GIT_PAGER=less git log -p --ext-diff --pretty=format:'%C(bold yellow)%H%Creset%C(auto)%d%Creset %s %Cgreen%ci %C(yellow)(%cr) %C(bold blue)<%an>%Creset'"} {split-window -h -l "70%" -c '#{pane_current_path}' git log -p}} {if -F '#{m:git diff,#{pane_start_command}}' {split-window -l "95%" -c '#{pane_current_path}' bash -c "GIT_EXTERNAL_DIFF=sift GIT_PAGER=less git diff --ext-diff"} {split-window -h -l "60%" -c '#{pane_current_path}' git diff}}
# # Suitable to have a bind to go straight to commit because git add via nvim-tree is the go to now.
# bind -n M-c split-window -c '#{pane_current_path}' ~/util/commit-push-interactive.sh
# bind -n M-C split-window -h -c '#{pane_current_path}' ~/util/commit-push-interactive.sh
bind -n F2 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:#{pane_current_command},ssh}}' "send-keys F2" "previous-window"
bind -n ™ if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:#{pane_current_command},ssh}}' "send-keys F2" "previous-window"
bind -n F3 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},htop}}}' "send-keys F3" "next-window"
bind -n £ if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},htop}}}' "send-keys F3" "next-window"
bind F2 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:#{pane_current_command},ssh}}' "previous-window" "send-keys F2"
bind ™ if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:#{pane_current_command},ssh}}' "previous-window" "send-keys F2"
bind F3 if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},htop}}}' "next-window" "send-keys F3"
bind £ if -F '#{||:#{m/r:^N?VIM,#{pane_title}},#{||:#{==:#{pane_current_command},ssh},#{==:#{pane_current_command},htop}}}' "next-window" "send-keys F3"
# bind -n F4 if '#{||:#{m/r:^N?VIM,#{pane_title}},#{==:#{pane_current_command},ssh}}' "send-keys F4" "copy-mode"
bind -n M-u if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys M-u" "swap-pane -U"
bind -n M-i if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "send-keys M-i" "swap-pane -D"
bind M-u if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "swap-pane -U" "send-keys M-u"
bind M-i if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' "swap-pane -D" "send-keys M-i"
bind -n M-y move-pane -t ':-'
bind -n M-o move-pane -t ':+'
bind M-y send-keys M-y
bind M-o send-keys M-o
bind C-b display-panes
bind b display-panes # looks like i am doing this a lot (for manipulation of panes)
set -g display-panes-time 2000
set -g display-time 2000
set -s set-clipboard on
# friendly for ctrl key state and also allow repeat
bind -r n next-window
bind -r C-n next-window
bind -r p previous-window
bind -r C-p previous-window
# bind C-C command-prompt -p "Make a new window running this command:" "new-window \"%%\""
# bind C-_ command-prompt -p "Make a new pane vsplit here running:" "split-window -v \"%%\""
# bind C-\ command-prompt -p "Make a new pane split here running:" "split-window -h \"%%\""
bind C-_ send-keys 'C-_'
bind 'C-\' send-keys 'C-\'
bind -n C-S-Left { swap-window -t -1; previous-window }
bind -n C-S-Right { swap-window -t +1; next-window }
# send C-a with prefix-a (unnecessary bind if prefix == C-a)
bind a send-keys C-a
# send prefix through with second C-a
bind C-a send-prefix
bind e last-window # convenience for iphone
# bind / list-keys # a shift-key relaxation overload (also good way to check if copycat is loaded)
unbind A
bind A command-prompt "rename-window %%"
# I'm a Vim user, this makes navigation easier
set -g mode-keys vi
# seems like it got taken out recently or something
set -g repeat-time 350
# these are the fallback pane movement controls (you can nest arbitrarily and still be able to select w/o mouse)
unbind k
bind -r k select-pane -U
unbind j
bind -r j select-pane -D
unbind h
bind -r h select-pane -L
unbind l
bind -r l select-pane -R
# These include alternate prefix-fallbacks for resizing (can use plain arrow
# keys with prefix to do so as well)
bind -n M-h if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-h} {resize-pane -L 5}
bind -r M-h if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -L 5} {send-keys M-h}
bind -n M-j if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-j} {resize-pane -D 3}
bind -r M-j if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -D 3} {send-keys M-j}
bind -n M-k if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-k} {resize-pane -U 3}
bind -r M-k if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -U 3} {send-keys M-k}
bind -n M-l if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-l} {resize-pane -R 5}
bind -r M-l if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -R 5} {send-keys M-l}
bind -n M-m if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-m} {resize-pane -Z}
bind -n M-M if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -Z} {send-keys M-m}
# this is a fallback
bind -r M-m if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -Z} {send-keys M-m}
# (wrong spot for doing this translation (maybe see if ssh can do it?) but w/e) these keys are what
# by default the opt key binds do on an ipad in shelly. I am keeping it here since there are
# precious few bindable keys on there and it remains the fastest terminal on iOS, so this is still
# a good relief valve.
bind -n ˙ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-h} {resize-pane -L 5}
bind -r ˙ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -L 5} {send-keys M-h}
bind -n ∆ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-j} {resize-pane -D 3}
bind -r ∆ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -D 3} {send-keys M-j}
bind -n ˚ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-k} {resize-pane -U 3}
bind -r ˚ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -U 3} {send-keys M-k}
bind -n ¬ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {send-keys M-l} {resize-pane -R 5}
bind -r ¬ if -F '#{&&:#{==:#{pane_current_command},ssh},#{||:#{==:1,#{window_panes}},#{window_zoomed_flag}}}' {resize-pane -R 5} {send-keys M-l}
bind -n ≤ "send-keys M-,"
bind -n ≥ "send-keys M-."
# Shift-versions of these keys send the non shifted version of themselves
# through to pane. This is good for both nested tmuxes and also any programs
# that respond to those particular keys I have Vim respond to these sequences
# in order to do a move-window-all-the-way-<direction>
bind -n M-H send-keys M-h
# bind -n Ó send-keys M-h
# bind -r Ó send-keys M-H
bind -n M-J send-keys M-j
# bind -n Ô send-keys M-j
# bind -r Ô send-keys M-J
bind -n M-K send-keys M-k
# bind -n send-keys M-k
# bind -r send-keys M-K
bind -n M-L send-keys M-l
# bind -n Ò send-keys M-l
# bind -r Ò send-keys M-L
# bind -n  send-keys M-m
# bind -r  send-keys M-M
bind M-H send-keys M-H
bind M-J send-keys M-J
bind M-K send-keys M-K
bind M-L send-keys M-L
bind -r up resize-pane -U 3
bind -r down resize-pane -D 3
bind -r left resize-pane -L 5
bind -r right resize-pane -R 5
# handier session switching since i have to do it pretty much every time
# i reconnect (now i am disabling hopefully temporarily because it blows away
# env) (ok i think the last statement in parens was pre-adding the -E flag
# which i worked pretty hard to get the tmux guys to accept my PR)
bind -n M-) switch-client -n -E
bind -n M-( switch-client -p -E
# '0' is at the wrong end of the keyboard -- note I also use scripts that depend on this.
set -g base-index 1
set -g pane-base-index 1
# Scroll your way into copy mode (scrollback buffer)
# and select text for copying with the mouse
set -g mouse on
# Mouse bindings -- it is sufficient for now to combine it to arrows but
# eventually it would be nice to differentiate (at minimum, do this: detect if
# vim, and do not send up/down in that case)
# This provides the capability of mousewheel in man/less/etc which is huge
# This is what I wrote and came up with. its a bit shabby.
# bind -n WheelUpPane if "[[ #{pane_current_command} =~ vim ]]" "select-pane -t = ; send-keys -M" "select-pane -t = ; send-keys Up"
# bind -n WheelDownPane if "[[ #{pane_current_command} =~ vim ]]" "select-pane -t = ; send-keys -M" "select-pane -t = ; send-keys Down"
# This, i ripped from a site (sc0ty.pl) and it is very nice because it allows
# scrolling and shit in a DIFFERENT pane while keeping the focus intact...
# wow...
# bind-key -n WheelUpPane \
# if -Ft= "#{?pane_in_mode,1,#{mouse_button_flag}}" \
# "send-keys -Mt=" \
# "if -Ft= '#{alternate_on}' \
# 'send-keys Up Up Up Up' \
# 'copy-mode'"
# bind-key -n WheelDownPane \
# if -Ft= "#{?pane_in_mode,1,#{mouse_button_flag}}" \
# "send-keys -Mt=" \
# "send-keys Down Down Down Down"
bind -n WheelUpStatus previous-window
bind -n WheelDownStatus next-window
bind -n DoubleClick1Status resizep -Z
# bind F5 \
# display-message -p 'pane_in_mode: #{pane_in_mode} mouse_button_flag: #{mouse_button_flag} alternate_on: #{alternate_on} pane_title: #{q:pane_title} pane_current_command: #{pane_current_command}'
# bind -n F6
# hotkey to:
# switch to marked target, prevent manual interaction on it, ensure an adjacent
# window has ~/util/.tmux-exec open in vim and then execute ~/util/.tmux-exec
# in it.
# select-pane -t {marked}
setw -g alternate-screen on
# Toggle sending keystrokes to all panes in a window
# bind-key a set-window-option synchronize-panes
set -g update-environment "PATH DISPLAY COLORTERM SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY GIT_AUTHOR_NAME TMUX_SESSION_NAME GIT_DELTA_HYPERLINK_FORMAT"
set -g status-keys vi
set -g focus-events on # This is apparently new and helps for iterm/vim integration
set -g status-bg '#303030'
set -g status-fg '#cfcfcf'
set -g status-position top
set -g status-left-length 30
#this client_prefix variable is only available in post 1.7
set -g status-left "#[reverse]#{?client_prefix,#[fg=red] TMUX #[noreverse]#[bg=#606060]#[reverse]#[bg=default],}#[fg=#606060] #{s|.*/||:,#{socket_path}} #[fg=#303030]#[bg=#606060] #{session_name} "
set -g status-right-length 150
# the tr part also conveniently inserts a trailing space!
set -g status-right '#[fg=green]#(pgrep -P "#{pane_pid}" | tr "\n" " ")#[fg=#f99157]%H:%M:%S #[fg=red]%d-%b-%y'
setw -g window-status-style 'bg=#242424 fg=#757575'
setw -g window-status-current-style 'bg=#484848,bold'
# setw -g automatic-rename on
set -g allow-rename off
setw -g allow-rename off
set -gs history-file ~/.tmux-history
# This is very useful e.g. for debugging long script. when the debugger trips,
# we get the notification for the stoppage from another window
setw -g window-status-activity-style 'italics'
setw -g window-status-bell-style 'underscore'
set -g visual-bell off
set -g window-status-format '#[bg=#242424,fg=#303030]#[fg=#242424]#I#[fg=#959595]#{=/-12/…:window_name}#[fg=#656565]#F #[fg=#242424,bg=#303030]'
set -g window-status-current-format '#[bg=#484848,fg=#303030]#[fg=#484848]#I#[fg=#b5b5b5]#W#[fg=#959595]#F #[fg=#757575]#{=/-25/…:pane_title} #[fg=#484848,bg=#303030]'
set -g window-status-separator ''
setw -g pane-active-border-style "bg=#3f3f3f fg=#808080"
setw -g pane-border-style "bg=#1e1e1e fg=#6f6f6f"
# set -g pane-active-border-bg colour245
# set -g pane-active-border-fg colour232
# set -g pane-border-fg colour247
# This command sends stderr to the log file (no easy way to 2>> or 2> >:
# https://stackoverflow.com/a/420735/340947) so if we tail it and see activity, something is broken
# in the format tool.
# A "bug" is present where newlines in pane_title cause args to get shifted in the callee. a switch
# to double quoting seems to help this fail more gracefully. Follow
# https://github.com/tmux/tmux/issues/3406
setw -g pane-border-format "#($HOME/util/tmux-pane-border-format-generator #{q:pane_title} #{q:pane_current_path} #{pane_pid} #{pane_current_command} #{pane_index} #{window_index} #{session_name} 2> ~/.tmux-pane-border-format-generator.errlog)"
# setw -g pane-border-format "test"
# setw -g pane-border-format ' "#{=/-100/…:pane_title}" #[fg=#7f9f7f]#{s|#{@home}|~|:pane_current_path} #[fg=#6f6f6f]#(pgrep -P #{pane_pid}) #[fg=#7f7fff]#(ps -p "$(pgrep -P "#{pane_pid}" | tr "\n" " " | sed s/.$//)" -o args= | sed -E "s/(.{30})(.{2,})(.{20})$/\1…\3/" | sed -z -e s/\\n/\;/g -e s/.$//)#[fg=#6f6f6f] #{?alternate_on,<Alt Mode> ,}clds[#(pgrep -P "$(pgrep -P #{pane_pid})" | tr "\n" " " | sed s/.$//): #(ps -p "$({ pgrep -P #{pane_pid} || echo "#{pane_pid}" } | sed -z -e s/\\n/,/g -e s/.$//)" -o args= | sed -E "s/(.{30})(.{2,})(.{20})$/\1…\3/" | sed -z -e s/\\n/\;/g -e s/.$//)]'
setw -g pane-border-status top
set -s escape-time 5
setw -g aggressive-resize on
setw -g xterm-keys on
#unbind C-Left
#unbind C-Right
#unbind C-Up
# override binds so i can search faster, and prefix+question for list-keys
# makes more sense also.
bind ? list-keys
bind / copy-mode \; send-key ?
bind -T copy-mode-vi J send-keys -N 5 -X cursor-down
bind -T copy-mode-vi K send-keys -N 5 -X cursor-up
bind -T copy-mode-vi H send-keys -N 7 -X cursor-left
bind -T copy-mode-vi L send-keys -N 7 -X cursor-right
bind -T copy-mode-vi Up send-keys -X scroll-up
bind -T copy-mode-vi Down send-keys -X scroll-down
bind -T copy-mode-vi Right send-keys -N 7 -X scroll-down
bind -T copy-mode-vi Left send-keys -N 7 -X scroll-up
set -g renumber-windows on
#unbind C-Down
# bind \ split-window -h
# bind - split-window
# override the regular ones with one that replicates the directory you are
# currently in
bind '\' split-window -h -c '#{pane_current_path}'
bind - split-window -c '#{pane_current_path}'
set -wg monitor-activity on
set -g activity-action none
set -wg monitor-bell on
set -g bell-action any
set -g history-limit 50000
# the history-file is completely useless.
# set -g history-file '~/.tmux_history'
# these are "overloads" on the create-pane, they create panes from existing panes/windows, to allow rearrangement
bind _ command-prompt -p "create pane from existing: [session]:window[.pane] " "join-pane -s '%%'"
bind | command-prompt -p "create vpane from existing: [session]:window[.pane] " "join-pane -h -s '%%'"
# bind @ command-prompt -p "here is the prompt for the command" "run-shell \"tmux display-message -p 'i run in the pane currently focused which is #I;#P'; tmux break-pane -t %%; tmux display-message \\\"broke pane out into #I;#P\\\"; \" "
# Here is a jewel of a bind which does the task of flipping the orientation of the current pane with the pane before it (in the ordering) -- I had a SO question on this and nobody answered.
# Think F for flip
bind -n M-f move-pane -t '.-'
bind -n M-r move-pane -h -t '.-'
bind -n S-Up move-pane -h -t '.{up-of}'
bind -n S-Right move-pane -t '.{right-of}'
bind -n S-Left move-pane -t '.{left-of}'
bind -n S-down move-pane -h -t '.{down-of}'
bind M-f send-keys M-f
bind M-r send-keys M-r
bind M-F send-keys M-F
bind M-R send-keys M-R
# Needed a bind to d/c hung clients, because that happens a lot.
bind X confirm-before -p "detach all other clients? (y/n)" "detach-client -a"
set -g wrap-search off
# This is a bind to prompt for assigning something to monitor and highlight for
# this is good for long running scripts that dont stop but still require
# supervision.
# bind M command-prompt -p "Initiating window monitoring. Type the content you
#want me to alert on." "setw monitor-content %%"
# setw -g window-status-content-style 'bg=#00ff00,fg=#000000,bold'
# As of Tmux 2 this functionality appears to have been removed. we can use
# visual-silence or some similar feature
# visual-silence off, by itself, makes silence send bell, which is aggravating. We set all these
# to make it so it will show up silently.
set -g silence-action none
set -wg visual-silence off
set -wg monitor-silence 5
# justify the window list on the left. The reason for this is that centering
# will cause the list to jump around too much as the right-side status changes
# length. it is horrifyingly annoying.
set -g status-justify left
set -g window-style 'bg=terminal'
set -g window-active-style 'bg=#000000'
# just experimenting -- i'm still looking for hooks for a few things that seem
# unimplemented yet...
# set-hook -g 'after-split-window' 'display-message "split!"'
# F8/F9 began as a test from suggestion on tmux mailing list to do conditional
# zoomed next pane behavior. That works, and is mainly for use in hugely
# constrained tmux sessions such as phone screen or tiny tmux sub-window with
# ssh session. I am overloading it a few levels deep to give it the following
# behavior:
# base behavior is F8 goes back a pane, F9 goes forward pane. If already
# zoomed, immediately re-zoom (tmux appears to efficiently trigger this). This
# means it is practical to attach to a "big" tmux session with a small window
# and automagically treat the panes in a window as "windows".
# this is then extended with behavior that tunnels when a tmux pane is running
# ssh. This is to support that aforementioned case such that F8/9 tunnel
# through (like F10 does but only for ssh) to make a useful remote server
# workspace inside of a small tmux pane. With this we also can finally relax
# F10 tunneling with ssh (which can be a nuisance)
bind -n F9 if -F '#{==:#{pane_current_command},ssh}' {send-keys F9} {if -F '#{window_zoomed_flag}' {selectp -t:.+; resizep -Z} {selectp -t:.+}}
bind -n F8 if -F '#{==:#{pane_current_command},ssh}' {send-keys F8} {if -F '#{window_zoomed_flag}' {selectp -t:.-; resizep -Z} {selectp -t:.-}}
bind F8 send-keys F8
bind F9 send-keys F9
# Window selection via alt+number. I still havent invented esc seqs for ctrl+number yet but alt+number is more
# ergonomic via thumb.
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
bind -n M-0 select-window -t 10
# bind -n F7 if -F "#{window_zoomed_flag}" "display-message \"zoomed dont know about vim\"" "if
# \"case \\\"#{pane_current_command}\\\" in *vim*) exit 0;; *) exit 1;; esac\" \"display-message
# 'nonzoomed in vim'\" \"display-message 'nonzoomed not in vim'\""
# List of plugins
# Supports `github_username/repo` or full git repo URLs
# Other examples:
# github_username/plugin_name \
# git@github.com/user/plugin \
# git@bitbucket.com/user/plugin \
# set -g @resurrect-strategy-nvim 'session'
# set -g @resurrect-strategy-vim 'session'
# set -g @continuum-restore 'on'
set -g @resurrect-processes '"vim -S->vim -S" "nvim -S->nvim -S" ssh top htop "sudo htop" "sudo bmon" "sudo iotop" "sudo zpool iostat 1 -v" "/usr/bin/python /opt/ros/melodic/bin/roscore->rtr && roscore" "./devel/lib/rtr_appliance_app/rtr_appliance_app->rtr && RTR_LOG_STYLE=ALT4 RTR_LOG_LEVEL=DEBUG ./devel/lib/rtr_appliance_app/rtr_appliance_app" "/bin/bash /home/slu/util/npm-start->rtr && npm-start"'
set -g @resurrect-dir '~/.tmux-resurrect-save'
set -g @resurrect-capture-pane-contents 'on'
# Auto-install TPM if absent.
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"
set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @scroll-without-changing-pane "on"
set -g @scroll-speed-num-lines-per-scroll "3"
set -g @scroll-in-moused-over-pane "on"
set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# unbind -t vi-copy C-j
# I believe this sets bgcolor based on whether in copy mode or not. yea yellow corner offset indicator works but this
# helps make it more visually clear.
set-hook -g pane-mode-changed { if -F "#{pane_in_mode}" "set -p window-style bg=#100030 \; set -p window-active-style bg=#200040" "set -p window-style bg=terminal \; set -p window-active-style bg=#000000" }
# Add a much needed degree of responsiveness to status line
# set-hook -g window-resized
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'