-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
1322 lines (1097 loc) · 56.4 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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# If you happened to trigger this key combination (C-z) in vanila tmux, $mod+shift+q in wayland will save you
# https://superuser.com/questions/1271190/restore-tmux-client-after-suspend-client
# kill -CONT <pid>
# bind -T prefix C-z suspend-client
# How to debug
# \tmux -L test -f /dev/null
# \tmux source -nv $XDG_CONFIG_HOME/tmux/tmux.conf
# https://unix.stackexchange.com/questions/57641/reload-of-tmux-config-not-unbinding-keys-bind-key-is-cumulative
# Unbind ALL keybindings whilst REBINDING defaults
# unbind -a
# source ~/.tmux.reset.conf
run-shell ' export f=$(mktemp -t) \
&& \tmux -f /dev/null -L temp start-server \; list-keys > $f \
&& \tmux unbind -a -T copy-mode-vi \
&& \tmux unbind -a -T copy-mode \
&& \tmux unbind -a -T prefix \
&& \tmux unbind -a -T root \; source-file $f && rm -f $f '
# The following variables was set in ashrc::_tmux()
set-option -g update-environment "SHELL TERM XDG_CACHE_HOME HOST_NAME TMUX_TMPDIR HOME XDG_CONFIG_HOME XDG_DATA_HOME MNGR_ROOT PROFILE DISPLAY WAYLAND_DISPLAY XDG_RUNTIME_DIR SSH_AUTH_SOCK"
set-environment -g PATH "/usr/local/bin:/bin:/usr/bin:/usr/sbin"
# setenv -g TERM "tmux-256color"
setenv -g TERM "$TERM"
setenv -g SHELL "/bin/ash"
setenv -g XDG_CONFIG_HOME "$XDG_CONFIG_HOME"
%hidden level_0=1
%hidden level_1=1
%if #{level_0}
%if #{level_1}
%hidden nesting_support=1
%else
%hidden nesting_support=
%endif
%else
%if #{level_1}
%hidden nesting_support=
%else
%hidden nesting_support=
%endif
%endif
display -p "[0039] nesting_support == #{nesting_support}"
# Tmux .conf files that need to be inserted into the default tmux.conf, $XDG_CONFIG_HOME/tmux == $PROFILE/terminal/tmux
if '[ -s "$XDG_CONFIG_HOME/tmux/header.conf" ]' \
{
source "$XDG_CONFIG_HOME/tmux/header.conf"
} {
confirm-before -p "[0046] $XDG_CONFIG_HOME/tmux/header.conf is not a valid file. Kill server ? (y/n)" kill-server
}
bind -T root C-s run-shell "$XDG_CONFIG_HOME/tmux/tmux-layout-dwindle brvc"
# https://stackoverflow.com/questions/51181608/make-tmux-prefix-binding-always-act-as-prefix-and-prefix-only-idempotent-bindi
# bind -T root C-b switch-client -T prefix # Equivalent to 'set-option -g prefix C-b'?
# remap prefix from C-b to C-a
# bind C-a send-prefix
# set -g prefix C-a
# better prefix key
# set-option -g prefix C-a
# bind C-a send-prefix
# https://stackoverflow.com/questions/59717644/tmux-force-repeat-prefix-key-for-every-command?rq=3
# set-option -g repeat-time 0
set-option -g repeat-time 500
# Remove the delay of escape key
# set -sg escape-time 0
# set-option -sg escape-time 10
# nvim checkhealth reported error
set-option -sg escape-time 0
set-option -sg focus-events on
# set-option -g focus-events on
# Tab == Ctrl-I It is jump forward
# set-option -g prefix Tab
# bind Tab send-prefix
# unbind -n BTab
# set-option -g prefix BTab
# bind BTab send-prefix
# unbind -n S-Tab
# set-option -g prefix S-Tab
# bind S-Tab send-prefix
# Pass on Ctrl+Tab and Ctrl+Shift+Tab
# bind -n C-Tab send-keys Escape [27\;5\;9~
# bind -n C-S-Tab send-keys Escape [27\;6\;9~
# bind -n S-Tab send-keys Escape Tab
# bind -n S-Tab send-keys Shift_L Control_i
# https://unix.stackexchange.com/questions/751388/does-any-terminal-multiplexer-screen-tmux-zellij-support-job-suspension-ctr
# bind -T root C-z suspend-client
unbind -T root C-z
# This is an error
# bind -T root C-z ""
bind -T root C-z send-keys C-z
bind -T prefix C-z send-keys C-z
# For BSDs
# set -g status-utf8 on
# set -g utf8 on
# disable bell in tmux
# disable sound bell
set -g bell-action none
# disable visual bell
set -g visual-bell off
# set *sh as your default Tmux shell
# set-option -g default-shell "$SHELL" # not a suitable shell:
set-option -g default-shell "/bin/ash"
# set-option -g default-path "$HOME" # invalid option
set-option -g history-limit 640000 # lines
# Tmux command mode inputs go here
set-option -g history-file "$XDG_CACHE_HOME/tmux/history.log"
# Display status bar errors forever until any key press
set-option -g display-time 0
set -g display-panes-time 1000
# tmux show-option -gqv "@display-name"
# set-option -g @display-name 'WAYLAND_DISPLAY'
# tmux show-option -gqv "@display-value"
%if "#{DISPLAY}"
set-option -g @display-value "$DISPLAY"
%else
%if "#{WAYLAND_DISPLAY}"
# run -C 'set-option -g "@display-value" "$(printf "%s" "$WAYLAND_DISPLAY")"'
set-option -g @display-value "$WAYLAND_DISPLAY"
%hidden display_value="$WAYLAND_DISPLAY"
# https://www.guyrutenberg.com/2021/07/02/tmux-wayland-clipboard-integration/
set-option -g -s copy-command 'wl-copy'
# tmux show-option -gqv '@paste-command'
set-option -g @paste-command 'wl-paste --no-newline'
%endif
%endif
# https://invisible-island.net/ncurses/terminfo.src.html#tic-xterm_256color
# https://vi.stackexchange.com/questions/7112/tmux-messing-with-vim-highlighting
# https://stackoverflow.com/questions/45931164/duplicated-characters-and-non-updating-input-using-tmux-in-zsh
# https://github.com/alacritty/alacritty/issues/2487
# https://sunaku.github.io/vim-256color-bce.html
# In GUI
# [True Color (24-bit) and italics with alacritty + tmux + vim (neovim)](https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6)
# [Enable italic font on tmux](https://gist.github.com/gyribeiro/4192af1aced7a1b555df06bd3781a722)
# In tty
# How to set TERM
# 1. _tmux alias
# 2. default-terminal in tmux.conf
# neovim: checkhealth
# - ERROR $TERM should be "screen-256color" or "tmux-256color" in tmux. Colors might look wrong.
# https://github.com/neovim/neovim/issues/7353
# tmux-256color to be used inside of tmux (instead of screen)
# set-option -g default-terminal "tmux-256color"
# set-option -g default-terminal "screen-256color-bce-s"
# set-option -g default-terminal "screen-256color"
# set-option -g default-terminal "$TERM"
# env TERM="linux" nvim
# Quiting nvim cursor disappear and no cursor in insert mode -- desappeared when outside tmux $TERM == linux
# "h" does not work in copy-mode in terminal ? -- disappeared when removed h re-definition on copy-mode-vi
set-option -g default-terminal "tmux-256color"
# set-option -g default-terminal "xterm-256color"
# set-option -g default-terminal "screen-256color"
# Must use double quotes
set-option -su terminal-features
set-option -gu terminal-features
set-option -su terminal-overrides
set-option -gu terminal-overrides
%if 1
# set-default colorset-option -ga terminal-overrides ",xtrm-256color:Tc"
# terminal-overrides applies to the outside $TERM. It basically says: When starting tmux in a shell that has $TERM set to xterm-256color, add the Tc capability to tmux's internal image of tmux-256color to signalize it to use true colors.
# set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -ga terminal-overrides ",$TERM:Tc"
# - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
set-option -sa terminal-features ",$TERM:RGB"
set-option -sa terminal-features ",xterm-256color:RGB"
# tmux info | grep Tc
# https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
# TERM == tmux version
# set-option -g default-terminal "tmux-256color"
# TERM == linux version
# set-option -g default-terminal "$TERM"
# [How to pipe vim clipboard through tmux?](https://superuser.com/questions/1742713/how-to-pipe-vim-clipboard-through-tmux)
set-option -sa terminal-features ",$TERM:clipboard"
# set-option -sa terminal-features "foot:clipboard"
# When a new line is entered, the adjacent pane is pushed up -- "margins": decslrm margins.
# set-option -sa terminal-features ",$TERM:256:ccolour:cstyle:extkeys:focus:margins:overline:rectfill:RGB:strikethrough:sync:title:usstyle"
set-option -sa terminal-features ",$TERM:256:ccolour:cstyle:extkeys:focus:overline:rectfill:RGB:strikethrough:sync:title:usstyle"
# set-option -ga terminal-overrides "tmux-256color:RGB"
# set-option -as terminal-overrides "xterm*:sitm=\033[3m"
# set-option -as terminal-overrides "*-256color:Tc"
# set-option -ga terminal-overrides "xterm-256color:Tc"
# set-option -ga terminal-overrides "*256col*:Tc"
# Without this, neovim in tmux without cursorline
set-option -sa terminal-overrides ",*:RGB"
set-option -sa terminal-overrides ",*256col*:RGB"
set-option -sa terminal-overrides ",$TERM:RGB"
set-option -sa terminal-overrides ",*256col*:Tc"
# set-option -sa terminal-overrides "*24bit:Tc"
# https://superuser.com/questions/310251/use-terminal-scrollbar-with-tmux
set-option -ga terminal-overrides ",$TERM*:XT:smcup@:rmcup@"
# set-option -ga terminal-overrides "screen-256color*:XT:smcup@:rmcup@"
set-option -ga terminal-overrides ",$TERM:RGB"
# set-option -ga terminal-overrides "screen-256color:RGB"
set-option -ga terminal-overrides ",$TERM:Tc"
set-option -ga terminal-overrides ",*:cud1=\033[1B"
# set-option -ga terminal-overrides "*256col*:Tc:sitm=\033[3m"
# set-option -ga terminal-overrides "*256col*:kf3=\E[[C:kf4=\E[[D:kf5=\E[[E:smkx@:rmkx@"
%endif
# nvim:help tui-cursor-tmux
# set-option -ga terminal-overrides "*:Ss=\E[%p1%d q:Se=\E[ q"
# set-option -ga terminal-overrides "*:Ss=\033[%p1%d q:Se=\033[2 q"
# Works on GUI
# set-option -ga terminal-overrides "*:Ss=\033[%p1%d q:Se=\033[5 q"
set-option -ga terminal-overrides ",*:Ss=\033[%p1%d q:Se=\033[ q"
# set-option -ga terminal-overrides "*:Ss=\033[ q:Se=\033[ q"
# set-option -ga terminal-overrides "*:Ss=\033[34l:Se=\033[?8c"
# Reset
# set-option -ga terminal-overrides "*:Ss=\033[0 q"
# Cursor coordinates messed up
# set-option -ga terminal-overrides "*:Ss=\033[%p1%dD:Se=\033[25h\033[?112c"
# set-option -ga terminal-overrides "*:Ss=\033[%p1%dD:Se=\033[?112c"
#
# https://github.com/gigglegrig/dotfiles/blob/master/.tmux.conf
# Function keys doesn't work when using tmux/screen as TERM
# Cursor does not display in command mode in Neovim whit the following config
# https://superuser.com/questions/968942/why-does-tmux-create-new-windows-as-login-shells-by-default
# kf3=\033[C [F1/F2/F3/F4/F5]
# bind -n F2 send-keys 'OQ'
# bind -n F3 send-keys '[13~'
# bind -n F3 send-keys 'OR'
# bind -n 'OR' send-keys '[13~'
# bind -n 'C' send-keys '[13~'
# bind -n 'F3' send-keys '[[C'
# bind -n 'F5' send-keys '[[E'
# bind -n F5 send-keys \033[[E
# 1:1140/117:20
# https://www.youtube.com/watch?v=5r6yzFEXajQ&t=660s
# https://superuser.com/questions/767178/how-do-i-create-ctrl-key-bindings-in-vim-when-using-tmux
set-window-option -g xterm-keys on
# set-window-option -g xterm-keys off
# set-option -gw xterm-keys on
# set-option -g xterm-keys on
# set-option -g SuppressDEC 12
# set -s extended-keys on
set -s extended-keys always
#set -s extended-keys off
set-option -gu cursor-style
# set-option -g cursor-style 'blinking-bar'
# set-option -g cursor-style 'block'
# set-option -g cursor-style 'default'
# default, blinking-block, block, blinking-underline, underline, blinking-bar, bar.
set-option -g cursor-style 'underline'
# https://gist.github.com/simme/1297707
# set-option -g mouse-select-pane on
# set-option -g mouse-select-window on
# set-window-option -g mode-mouse on
# [O was printed to current buffer when vim lost focus
# set-window-option -g focus-filter on
# set-option -g focus-filter on
# set-option -g mouse on
set-option -g mouse off # display output 0
%if "#{mouse}"
%else
unbind -n M-MouseDown3Pane
unbind -n M-MouseDown3Status
unbind -n M-MouseDown3StatusLeft
unbind -T copy-mode-vi MouseDown1Pane
unbind -T copy-mode MouseDown1Pane
unbind -T copy-mode-vi MouseDrag1Pane
unbind -T copy-mode MouseDrag1Pane
unbind -T copy-mode-vi MouseDragEnd1Pane
unbind -T copy-mode MouseDragEnd1Pane
unbind -n MouseDrag1Pane
unbind -n MouseDrag1Border
unbind -n MouseDown1Pane
unbind -n MouseDown1Status
unbind -n MouseDown2Pane
unbind -n MouseDown3Pane
unbind -n MouseDown3Status
unbind -n MouseDown3StatusLeft
unbind -n WheelUpPane
unbind -n WheelDownPane
unbind -n DoubleClick1Pane
unbind -n TripleClick1Pane
unbind -n WheelUpStatus
unbind -n WheelDownStatus
unbind WheelUpPane
unbind WheelDownPane
unbind DoubleClick1Pane
unbind TripleClick1Pane
unbind -T copy-mode-vi WheelUpPane
unbind -T copy-mode-vi WheelDownPane
unbind -T copy-mode-vi DoubleClick1Pane
unbind -T copy-mode-vi TripleClick1Pane
unbind -T copy-mode WheelUpPane
unbind -T copy-mode WheelDownPane
unbind -T copy-mode DoubleClick1Pane
unbind -T copy-mode TripleClick1Pane
%endif
# show-options set-clipboard
set-option -g -s set-clipboard on
# https://github.com/ojroques/nvim-osc52
set-option -g -s allow-passthrough all # allow passthrough of escape sequences
# tmux show-environment
# tmux showenv | awk -F= -v key="$key" '$1==key {print $2}'
# tmux setenv -t ${SESSION_NAME} "key" "value"
# [The vi-copy and emacs-copy mode key tables are gone](https://github.com/tmux/tmux/commit/76d6d3641f271be1756e41494960d96714e7ee58)
# # bind v, y, Escape keys in vi-copy mode
# bind -t vi-copy v begin-selection
# bind -t vi-copy y copy-selection
# bind -t vi-copy Escape cancel
# bind -T vi-copy Escape send-keys -X cancel
# bind -T copy-mode-vi Escape send-keys -X cancel
# https://stackoverflow.com/questions/51639540/tmux-scroll-mode-vim-keybindings
# https://blog.sanctum.geek.nz/vi-mode-in-tmux/
# https://github.com/jbranchaud/til/blob/master/tmux/enabling-vi-mode.md
# turn on vi key mode
# ["set -w" is the exact same as "setw"](https://superuser.com/questions/1425920/different-between-set-g-and-setw-g-and-set)
# setw -g mode-keys vi
set-window-option -g mode-keys vi
# options: primary|secondary|clipboard
setenv -g @yank-selection 'clipboard'
# bind 'v' copy-mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi V send -X select-line
# bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel 'xclip -in -selection clipboard'
# bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel 'wl-copy -sel clip -i'
# bind -T copy-mode-vi y send-keys -X copy-selection 'wl-copy -sel clip -i'
# How to debug
# tmux display -p '#{@buffer_content}'
# %hidden buffer_content="" # test
set -gqu @buffer_content
# Works on wayland
# bind -T copy-mode-vi y send-keys -X copy-selection 'wl-copy'
# Version 03
# bind -T copy-mode-vi y run '[ -z "${WAYLAND_DISPLAY:+x}" ] && tmux send-keys -X copy-pipe || tmux send-keys -X copy-pipe "wl-copy -sel clip -i" ; \
# bind -T copy-mode-vi y run -C 'send-keys -X copy-pipe "wl-copy -sel clip -i" ; \
# bind -T copy-mode-vi y run -C 'send-keys -X copy-pipe ; \
# The line continuation after run does not work!
# bind -T copy-mode-vi y run '\
# [ -z "${WAYLAND_DISPLAY:+x}" ] && tmux send-keys -X copy-selection || \
# tmux send-keys -X copy-pipe "wl-copy -sel clip -i" ; \
# tmux set -q @buffer_content "$(\tmux show-buffer)"'
# Does not work in chroot
# bind -T copy-mode-vi y run '[ -z "${WAYLAND_DISPLAY:+x}" ] && tmux send-keys -X copy-selection || \
# tmux send-keys -X copy-selection "wl-copy -sel clip -i" ; \
# tmux set -q @buffer_content "$(\tmux show-buffer)"'
unbind -T copy-mode-vi y
# bind -T copy-mode-vi y run -C 'send-keys -X copy-selection "wl-copy"; \
# tmux set -q @buffer_content "$(\tmux show-buffer)"'
# This is the default setting -- It ensures that the tmux cache/buffer contents are sent to the system clipboard
bind -T copy-mode-vi y send-keys -X copy-pipe
# bind -T copy-mode-vi y send-keys -X copy-selection
# tmux send-keys -X copy-selection "wl-copy -sel clip -i" ; \
# copy-pipe "wl-copy -sel clip -i" won't work on copying to wayland clipboard
# tmux send-keys -X copy-pipe "wl-copy -sel clip -i" ; \
# bind -T copy-mode-vi y run -C 'set -q "@buffer_content" "$(\tmux show-buffer)"'
# bind -T copy-mode-vi y send-keys -X copy-selection "sed -e 's/\#/\\\\\#/g' -e 's/\?/\\\\\?/g' | tee /tmp/tmux"
unbind -T copy-mode-vi Enter
# Original definition
# bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel # default setting
# bind -T copy-mode-vi Enter send-keys -X copy-pipe
# bind -T copy-mode-vi Enter if-shell -F '#{selection_present}' 'send-keys -X copy-pipe' 'send-keys -X cancel'
bind -T copy-mode-vi Enter if-shell -F '#{selection_present}' 'send-keys -X copy-pipe'
# Default
# bind -T copy-mode-vi n send-keys -X search-again
# bind -T copy-mode-vi n if-shell -F '#{selection_present}' ' send-keys -X search-again ' ' next-window '
# bind -T copy-mode-vi p previous-window
# Default
# bind -T copy-mode-vi BSpace send-keys -X cursor-left
# bind -T copy-mode-vi BSpace previous-window
# bind <prefix> + p to "paste"
# unbind p
# Duplicated with prefix-]
# bind p paste-buffer -p
# bind p display -p '#{@buffer_content}'
# bind p run -C 'display -p "#{@buffer_content}"'
# bind p display '#{@buffer_content}'
unbind -T copy-mode-vi C-p
# bind -T copy-mode-vi C-p paste-buffer
# ctrl-shift-v
# Will wipe the tmux buffers
unbind -n C-p
# bind -n C-p paste-buffer -p
# bind -n C-p run "tmux set-buffer \"$(eval \"$(\tmux show-option -gqv \"@paste-command\")\")\"; tmux paste-buffer -p"
# Works. Tmux will transfer single quotes to double quotes
# bind -n C-p run '[ -z "$(\tmux show-option -gqv "@display-value")" ] || tmux set-buffer "$($(\tmux show-option -gqv "@paste-command"))"; tmux paste-buffer -p'
# Works
# bind -n C-p run '\
# [ -z "$(\tmux show-option -gqv "@display-value")" ] || \
# $(\tmux show-option -gqv "@paste-command") | tmux load-buffer -w - ; \
# tmux paste-buffer -p'
# Works
# bind -n C-p run '\
# [ -z "$(\tmux show-option -gqv "@display-value")" ] || \
# $(\tmux show-option -gqv "@paste-command") | tmux load-buffer -w - ' \; \
# paste-buffer -p
bind -n "$paste_key" {
if-shell -F "#{@display-value}" {
run ' $(\tmux show-option -gqv "@paste-command") | tmux load-buffer -w - '
}
paste-buffer -p
}
unbind -T prefix :
# Works
# bind : run-shell "tmux set-option -wp pane-border-status off ; \
# tmux command-prompt -I \"#{l:$(\tmux show-buffer)}\" -p \">\""
# tmux command-prompt -I \"#{l:$(cat /tmp/tmux)}\" -p \">\""
# tmux command-prompt -I \"#{$(cat /tmp/tmux)}\" -p \">\" \"%%%\""
# sed -e 's/\#/\\\#/g' < /tmp/tmux > _ ; mv -f _ /tmp/tmux ; \
# Version 04 -- "pane-border-status off" depends on hook
# bind : command-prompt -I '#{@buffer_content}' -p '>'
# Version 03
# Works for formats
# bind : set-option -wp pane-border-status off \; \
# command-prompt -I '#{@buffer_content}' -p '>' \; \
# run -C 'set -u "@buffer_content"'
# # set -g window-active-style bg=terminal
# Does not work
# bind : set-option -wp pane-border-status off \; \
# set -q @buffer_content "#(tmux show-buffer)" \; \
# command-prompt -I "#{@buffer_content}" -p '>'
# Wroks
# -- tmux 3.4 supports C-y on vi == status-keys
# And from nvim/vim tmux clipboard integration, vim yank could directly port to tmux command mode
# by the vim-yank-transfer workflow without copy-mode yank
# But, for literally copy content without parsing the formats, you still need the following indirectly copy
# Paste just yanked content to command mode inputs
bind : set-option -wp pane-border-status off \; \
run '\tmux set -gq @buffer_content "#{l:$(\tmux show-buffer)}"' \; \
command-prompt -I "#{@buffer_content}" -p '>'
# Wroks for non-formats only
# bind : set-option -wp pane-border-status off \; \
# run 'tmux command-prompt -I "#{l:$(\tmux show-buffer)}" -p ">"'
# Does not work
# bind : set-option -wp pane-border-status off \; \
# command-prompt -I '#(tmux show-buffer)' -p '>'
# run -C 'set -u "@buffer_content" ; tmux set-option -wp pane-border-status bottom'
# command-prompt -I "#{l:#(tmux show-buffer)}" -p ">"
# Won't wait for enter
# bind : set-option -wp pane-border-status off \; \
# command-prompt -I '#{@buffer_content}' -p '>' \
# set-option -wp pane-border-status bottom
# "-k" doesn't work
# command-prompt -k -I '#{@buffer_content}' -p '>' \
# https://github.com/vimpostor/vim-tpipeline
# Default
# bind-key : command-prompt -p "(goto line)" "send -X goto-line \"%%%\""
# # bind : command-prompt 'set -g status-left "#{pane_id}"'
# bind : set-option -wp pane-border-status off \; command-prompt \; set-option -wp pane-border-status bottom
# bind : set-option -wp pane-border-status off \; command-prompt
# Works for formats
# bind : set-option -wp pane-border-status off \; \
# run -C 'set -q @buffer_content "$(\tmux show-buffer)"' \; \
# command-prompt -I "\#{@buffer_content}" -p \> \; \
# run -C 'set -u @buffer_content'
# Won't work
# set -q @buffer_content_01 "#(tmux show-buffer)" \; \
# just work for plain-text
# command-prompt -I "\#(cat /tmp/tmux)" -p \> \; \
# set -ru @buffer_content_01
# The main reason show-buffer being failed is this line -- the "run"
# run 'command-prompt -I "\#{@buffer_content_01}" -p \> \;' \
# Works for plain-text
# bind : run-shell 'tmux set-option -wp pane-border-status off; tmux command-prompt -I "$(\tmux show-buffer)" -p \>'
# bind : 'run-shell "tmux set-option -wp pane-border-status off; tmux command-prompt -I \"\$(\tmux show-buffer)\" -p \\>"'
# Works for plain-text
# bind : run-shell "tmux set-option -wp pane-border-status off ; \
# tmux command-prompt -I \$(\tmux show-buffer | sed 's/\#/\\\#/g') -p \">\""
# bind : run-shell "tmux set-option -wp pane-border-status off ; \
# tmux show-buffer | sed 's/\#/\\\#/g' | tee /tmp/tmux > /dev/null ; \
# tmux command-prompt -I \$(cat /tmp/tmux) -p \">\""
# tmux command-prompt -I $(\tmux show-buffer | sed -e 's/[\"\\]/\\\\&/g' -e 's/.*/\"&\"/') -p >'
# Partially Worked
# When cursor line is a tmux script, this function will fail (enter view mode)
# bind : run-shell "tmux set-option -wp pane-border-status off ; \
# tmux command-prompt -I \"\#{copy_cursor_word}\" -p \">\""
# Works
# bind : set-option -wp pane-border-status off \; \
# command-prompt -I "#{copy_cursor_word}" -p ">"
# Won't work
# bind : run-shell "tmux set-option -wp pane-border-status off \; tmux command-prompt -I $(printf %s $(\tmux show-buffer)) -p \>"
# bind : set-option -wp pane-border-status off \; command-prompt -I '#(sh "$(echo $(\tmux show-buffer))")' -p \>
bind -T copy-mode-vi u send-keys -X halfpage-up
bind -T copy-mode-vi , send-keys -X halfpage-down
bind -T copy-mode-vi m send-keys -X halfpage-down
# bind -T copy-mode C-r command-prompt -i -I "#{pane_search_string}" -p "search up>" "send -X search-backward-incremental \"%%%\""
# bind -T copy-mode C-s command-prompt -i -I "#{pane_search_string}" -p "(search down)" "send -X search-forward-incremental \"%%%\""
# bind -T copy-mode-vi / command-prompt -p "(search down)" "send -X search-forward \"%%%\""
# bind -T copy-mode-vi \# send-keys -FX search-backward "#{copy_cursor_word}"
# bind -T copy-mode-vi * send-keys -FX search-forward "#{copy_cursor_word}"
# unbind -T copy-mode-vi /
# bind -T copy-mode-vi \\ command-prompt paste-buffer -p "send -X search-forward \"%%%\""
unbind -T copy-mode-vi \\
# Won't work
# bind -T copy-mode-vi \\ command-prompt "send -X search-forward \"#{copy_cursor_word}\""
# bind -T copy-mode-vi \\ send-keys -X copy-selection \; "send -X search-forward \"%%%\""
# bind -T copy-mode-vi \\ send-keys -X copy-selection send -X search-forward "%%%"
# Works
# bind -T copy-mode-vi \\ command-prompt -I "#{copy_cursor_word}" -p "search up>" "send -X search-forward \"%%%\""
# bind -T copy-mode-vi \\ run-shell 'tmux command-prompt -I "$(\tmux show-buffer)" -p "search up>" "send -X search-forward \"%%%\""'
# bind -T copy-mode-vi \\ run -C 'command-prompt -I "$(\tmux show-buffer)" -p "search up>" "send -X search-backward \"%%%\""'
# Works Version 03
# bind -T copy-mode-vi \\ set-option -wp pane-border-status off \; \
# command-prompt -I '#{@buffer_content}' -p 'search up>' 'send -X search-backward "%%%"'
# Works Version 04
bind -T copy-mode-vi \\ set-option -wp pane-border-status off \; \
send-keys -X copy-selection \; \
run '\tmux set -q @buffer_content "#{l:$(\tmux show-buffer)}"' \; \
command-prompt -I '#{@buffer_content}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run -C 'set -u "@buffer_content"'
# Works Version 05
# bind -T copy-mode-vi \\ {
# set-option -wp pane-border-status off
# if-shell -F '#{selection_present}' {
# send-keys -X copy-selection
# }
# run '\tmux command-prompt -I "#{l:$(tmux show-buffer)}" -p "search up>" "send -X search-backward \"%%%\""'
# }
# run -C 'set -u "@buffer_content" ; tmux set-option -wp pane-border-status bottom'
# send-keys -X -t '\#(cat #{pane_id})' copy-selection \; \
unbind -T copy-mode-vi :
# Works Version 04
bind -T copy-mode-vi : set-option -wp pane-border-status off \; \
send-keys -X copy-selection \; \
run '\tmux set -q @buffer_content "#{l:$(\tmux show-buffer)}"' \; \
command-prompt -p '>' -I '#{@buffer_content}' \; \
run -C 'set -u "@buffer_content"'
# run -C 'set -u "@buffer_content" ; tmux set-option -wp pane-border-status bottom'
# Works Version 05
# bind -T copy-mode-vi : {
# set-option -wp pane-border-status off
# if-shell -F '#{selection_present}' {
# send-keys -X copy-selection
# }
# run '\tmux command-prompt -p ">" -I "#{l:$(tmux show-buffer)}"'
# }
# run -C 'command-prompt -p "cmd:" -I "$(\tmux show-buffer)"'
# command-prompt -p "cmd:" -I 'send-keys -X copy-selection-no-clear ; run-shell "tmux show-buffer | %%%" '
# command-prompt -p "cmd:" -I 'send-keys -X copy-selection-no-clear ; run-shell "tmux show-buffer | %1" '
# This will lock tmux (c-q to quit)
# bind V run-shell "'tmux capture-pane' \; tmux capture-pane -S - \; tmux save-buffer /tmp/tmux \; \
# nvim \"+normal\ G\" +\"?^> \" /tmp/tmux"
# send-keys Escape 'invim "+normal\ G" +"?^> " /tmp/tmux' Enter
set -g status-keys vi
set-window-option -g status-keys vi
# no crrrent session
# set status-interval 1
# set -s status-interval 1
# set -g status-interval 1
set -g status-interval 50
# set-hook -g after-command-prompt 'set-option -wp pane-border-status bottom'
# set-hook -g after-refresh-client 'set-option -wp pane-border-status bottom'
# set-hook -g after-resize-pane 'set-option -wp pane-border-status bottom'
# set-hook -g after-resize-window 'set-option -wp pane-border-status bottom'
# set-hook -g after-queue 'set-option -wp pane-border-status bottom'
# set-hook -gu after-command-prompt
set-hook -gu after-refresh-client
set-hook -gu after-resize-pane
set-hook -gu after-resize-window
set-hook -gu after-queue
set-hook -gu client-resized
set-hook -gu pane-mode-changed
# set-hook -gu paste-buffer-changed
set-hook -gu after-set-option
# tmux show-hooks -g
set-hook -g after-queue[0] 'set-option -wp pane-border-status off'
# set-hook -g paste-buffer-changed["buffer0"] 'run -C "show-buffer | wl-copy"'
# set-hook -g paste-buffer-changed["buffer0"] 'run -C "save-buffer - | wl-copy"'
# Just disable the hook because it is counter intuitive :)
# set-hook -g after-resize-pane[0] 'run-shell "! { tmux list-panes -F \"#F\" | grep -q Z; } && \
# tmux set-option -wp pane-border-status off || \
# tmux set-option -wp pane-border-status top"'
# This is because if you don't turn off tmux screen occupation, the display status of some terminal applications might be very confusing
# set-hook -g after-resize-pane[0] 'run-shell "! { \tmux list-panes -F \"#F\" | grep -q Z; } || { \tmux set-option -wp pane-border-status off; \tmux refresh-client; }"'
set-hook -g after-resize-pane[0] "
# if-shell '{ \tmux list-panes -F \"#F\" | grep -q Z; }' {
if-shell -F '{ \tmux list-panes -F \"#F\"; }' {
set-option -wp pane-border-status off # bottom
# refresh-client -t '#{session_id}:#{window_id}.$TMUX_PANE'
refresh-client
}
"
# set-hook -g after-resize-pane 'run-shell "tmux list-panes -F \"#F\" | grep -q Z && \
# tmux set-option -wp pane-border-status bottom || \
# tmux set-option -wp pane-border-status off"'
# set -g status-left '#(cat #{socket_path}-\#{session_id}-vimbridge)'
# set -g status-left-length 80
# set -g status-right '#(cat #{socket_path}-\#{session_id}-vimbridge-R)'
# # https://stackoverflow.com/questions/12921852/tmux-conf-update-status-commands-on-panel-focus?noredirect=1&lq=1
# set -g status-right '#(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD)'
# set -g status-right-length 80
# set -g status-justify right
# set -g status-right '#{prefix_highlight} | %a %Y-%m-%d %H:%M'
# set inactive/active window styles
# https://stackoverflow.com/questions/25532773/change-background-color-of-active-or-inactive-pane-in-tmux
# https://superuser.com/questions/480809/updating-window-indexes-with-tmux
set-option -g renumber-windows on
# https://www.reddit.com/r/tmux/comments/8mfc2d/looking_for_a_way_to_format_paneborderstatus_via/
# https://github.com/tmux/tmux/issues/1852
# Remove tmux's status bar
set -g status off
# https://stackoverflow.com/questions/22303820/tmux-transparent-status-bar
# error 'no current session'
# set -g status-bg colour240
# set -g status-bg default
set -g status-bg terminal
# set -g status-style bg=default
set -g status-style bg=terminal
# set -g pane-border-lines number
set -g pane-border-lines single
# Get the border status
# show-option -vqp pane-border-status
# Default pane-border-status
set -g pane-border-status off
# set -g pane-border-status left
# set -g pane-border-status bottom
# set -g pane-border-status top
# %hidden background="colour147"
%hidden foreground="default"
%hidden background="terminal"
# %hidden background="colour021"
# [tmux_256_colors.pl](https://gist.github.com/invalidusrname/1101565)
# Color settings might erase the transparency
# better splitting
# set the pane border colors
# set -g pane-border-style 'fg=default, bg=default'
# set -g pane-border-style 'fg=#111111, bg=default'
# set -g pane-border-style 'fg=colour020, bg=colour020'
set -gF pane-border-style "fg=#{foreground},bg=terminal"
# set -gF pane-border-style 'fg=terminal, bg=terminal'
# set -gF pane-border-style "hidden"
# set -g pane-border-style 'hidden'
# set -g pane-active-border-style 'fg=default, bg=default'
# set -g pane-active-border-style 'fg=colour102, bg=default'
# set -g pane-active-border-style 'fg=#222222, bg=default'
# set -g pane-active-border-style 'fg=colour14, bg=default'
# set -g pane-active-border-style 'fg=colour020, bg=terminal'
# set -g pane-active-border-style 'fg=colour020, bg=colour020'
set -gF pane-active-border-style "fg=#{foreground},bg=terminal"
# set -g pane-active-border-style 'hidden'
# set -g window-style 'fg=colour247, bg=colour236'
# set -g window-style 'fg=default, bg=#{background}'
set -gF window-style "fg=default,bg=terminal"
# set -g window-style 'fg=default, bg=default'
# set -g window-style 'hidden'
# set -g window-active-style 'fg=colour247, bg=colour234'
# This setting will dim shell PS1
# set -g window-active-style 'fg=#111111, bg=default'
# set -g window-active-style 'fg=default, bg=default'
# https://unix.stackexchange.com/questions/494237/tmux-is-it-possible-to-dim-the-inactive-window-and-on-the-same-time-have-transp
#
# prefix_key_4/4 -- handling state indicators
#
# Test this static setting off for dynamic setting
# set -g window-active-style 'fg=default, bg=terminal'
# bind -T prefix b set-option -wp pane-border-status bottom
bind -T prefix b \
if-shell -b '[ "$(\tmux show -pqv "#{pane-border-status}")" = "off" ]' 'set-option -wp pane-border-status top' 'set-option -wp pane-border-status off'
# echo -ne "\e]2;New Title\007"
set-option -g set-titles on
set -g allow-rename on
# set-window-option -g automatic-rename off
set-option -g automatic-rename on
# Will send keystrokes to all panes
# set-window-option -g synchronize-panes on
# set-option -t 0 remain-on-exit on
# tmux respawn-pane -k -t 3.1 nvim $XDG_CONFIG_HOME/tmux/tmux.conf
# https://www.reddit.com/r/tmux/comments/55i80p/tmux_statusbar_inside_pane_rather_than_bottomtop/
# set-window-option -g pane-border-format " #P: #{pane_current_path} #{pane_current_command} "
# set -g pane-border-format "#{pane_current_path}"
# if "[ $(\tmux display -p '#{pane_current_command}') = 'nvim' ]" \
# if-shell "$is_vim" \
# "set-window-option -g pane-border-format ' #P: #{pane_current_path} #{pane_title} #(cat #{socket_path}-\#{session_id}-vimbridge) #(cat #{socket_path}-\#{session_id}-vimbridge-R) '" \
# "set-window-option -g pane-border-format ' #P: #{pane_current_path} #{pane_title} ) '"
# Must use single quote
# set-window-option -g pane-border-format ' #{pane_title} #(cat #{socket_path}-\#{session_id}-vimbridge) #(cat #{socket_path}-\#{session_id}-vimbridge-R) '
# run '(tmux display-message -p "#{pane_title}" | grep -i "NVIM" \
# && "set-window-option -g pane-border-format \" #P: #{pane_current_path} #{pane_title} #(cat #{socket_path}-\#{session_id}-vimbridge) #(cat #{socket_path}-\#{session_id}-vimbridge-R) \" " ) \
# || "set-window-option -g pane-border-format \" #{pane_index} #{pane_current_command} #{pane_current_path} #{pane_title} ) \" " '
# "date" format
# -- $(date +%a\ %b\ %d,\ %H:%M:%S\ %Z\ %Y)\n\
# https://www.markneuburger.com/git-statuses-in-tmux-panes/
set-window-option -g window-status-separator ''
set -g window-status-current-style bg=white
set-window-option -g window-status-current-format ' \
#{?window_zoomed_flag, #[fg=red]#[italics], #[fg=default]#W#[fg=default]} \
'
# How to reference: #{pane_border_format}
# But can not been interpreted by tmux by default
# %hidden pane_border_format=' \
# #D : #P #T #{simple_git_status} \
# #(sh $XDG_CONFIG_HOME/tmux/pane-border-format \
# "--pane-current-path=#{pane_current_path}" "--pane-active=#{pane_active}") \
# #{pane_current_command} \
# #(date)'
set-window-option -g pane-border-format ' \
#{?window_zoomed_flag,#[fg=#ffffff]#[bg=#d70000],#[fg=#ffffff]#[bg=default]} \
#D : #P #T \
#($XDG_CONFIG_HOME/tmux/pane-border-format \
"--pane-current-path=#{pane_current_path}" "--pane-active=#{pane_active}") #{pane_current_command} #(date) '
# set-window-option -g pane-border-format ' \
# #{?window_zoomed_flag, #[fg=#d70000]#[bg=#ffffff]#[italics], #[fg=#007777]#[bg=default]} \
# #[fg=##007777] #D: #P #T #{simple_git_status} \
# #{pane_current_command} \
# #(cat #{socket_path}-\#{session_id}-vimbridge) \
# #(cat #{socket_path}-\#{session_id}-vimbridge-R) \
# #(sh $XDG_CONFIG_HOME/tmux/pane-border-format \
# "--pane-current-path=#{pane_current_path}" "--pane-active=#{pane_active}") \
# #(date)#[fg=default] \
# '
# #{?window_zoomed_flag, #[fg=#d70000]#[bg=#ffffff]#[italics], #[fg=black]#W#[fg=default]} \
# #[fg=#ffff00]#F#[fg=default] #P: #{pane_index} #{pane_title} #{simple_git_status} \
# #{pane_current_command} #{pane_current_path} \
# #P: #{pane_index} [#I #W#T] #{pane_title} #{simple_git_status} \
# https://gist.github.com/tsl0922/d79fc1f8097dde660b34
bind space next-window
bind bspace previous-window
# bind enter next-layout
# less colourful status
# https://medium.com/@findingedward/configuring-vim-and-tmux-to-boost-your-productivity-dab44ba7db11
set-option -g @pane_resize "5"
# No current window
set-option -g -u window-size
# set-option -g window-size largest
set-window-option -g aggressive-resize
set-window-option -g alternate-screen off
# split ratio
# use vim-like keys for splits and windows
bind \% run-shell '\tmux split-window -fbh -c "#{pane_current_path}"; \
\tmux resize-pane -t #{pane_id} -x $(( 2 * #{pane_width} / 3 ))'
bind \" run-shell '\tmux split-window -fbv -c "#{pane_current_path}"; \
\tmux resize-pane -t #{pane_id} -y $(( 2 * #{pane_height} / 3 ))'
# -y $(( $(\tmux display-message -p "#{pane_height}") / 3 ))'
# bind - run-shell '\tmux split-window -vb -c "#{pane_current_path}"; \
# $XDG_CONFIG_HOME/tmux/tmux-layout-dwindle tlvs'
# bind - run-shell '\tmux split-window -vb -c "#{pane_current_path}"; \
# \tmux resize-pane -t #{pane_id} -y $(( 2 * #{pane_height} / 3 ))'
bind - run-shell '\tmux split-window -v -c "#{pane_current_path}"; \
\tmux resize-pane -t #{pane_id} -y $(( 5 * #{pane_height} / 7 ))'
# bind \\ run-shell '\tmux split-window -fhb -c "#{pane_current_path}"; \
# $XDG_CONFIG_HOME/tmux/tmux-layout-dwindle tlhs'
# bind \\ run-shell '\tmux split-window -hb -c "#{pane_current_path}"; \
# \tmux resize-pane -t #{pane_id} -x $(( 2 * #{pane_width} / 3 ))'
bind \\ run-shell '\tmux split-window -h -c "#{pane_current_path}"; \
\tmux resize-pane -t #{pane_id} -x $(( 2 * #{pane_width} / 7 ))'
# bind _ run-shell '\tmux split-window -fbv -c "#{pane_current_path}"; \
# $XDG_CONFIG_HOME/tmux/tmux-layout-dwindle tlvs'
# bind _ run-shell '\tmux split-window -fv -c "#{pane_current_path}"; \
# \tmux resize-pane -t #{pane_id} -y $(( 2 * #{window_height} / 3 ))'
bind _ run-shell '\tmux split-window -fv -c "#{pane_current_path}"; \
\tmux resize-pane -t #{window_id} -y $(( 2 * #{window_height} / 7 ))'
# bind | run-shell '\tmux split-window -hb -c "#{pane_current_path}"; \
# $XDG_CONFIG_HOME/tmux/tmux-layout-dwindle tlhs'
# bind | run-shell '\tmux split-window -hf -c "#{pane_current_path}"; \
# \tmux resize-pane -t #{pane_id} -x $(( 2 * #{window_width} / 3 ))'
bind | run-shell '\tmux split-window -fh -c "#{pane_current_path}"; \
\tmux resize-pane -t #{window_id} -x $(( 2 * #{window_width} / 7 ))'
bind J join-pane -h -s !
# unbind '"'
# unbind %
# Does not work?
# bind -n S-Left move-pane -h -t '.{left-of}'
# Capital H same as h
bind < move-pane -h -t '.{left-of}'
# bind -n S-Right move-pane -h -t '.{right-of}'
bind > move-pane -h -t '.{right-of}'
# bind -n S-Up move-pane -h -t '.{up-of}'
bind , move-pane -h -t '.{up-of}'
# bind -n S-Down move-pane -h -t '.{down-of}'
bind . move-pane -h -t '.{down-of}'
# https://superuser.com/questions/1079462/tmux-keybinding-to-swap-pane-left-or-right?rq=1
# Works only in GUI environment
# bind -n M-\{ select-pane -L \; swap-pane -s !
# bind -n M-\} select-pane -U \; swap-pane -s !
# Works both in tty and GUI environments
bind -n M-[ select-pane -L \; swap-pane -s !
bind -n M-\\ select-pane -L \; swap-pane -s !
bind -n M-] select-pane -U \; swap-pane -s !
bind -n M-- select-pane -U \; swap-pane -s !
# # For Void Linux
# # ctrl + return
# bind -T copy-mode-vi "\x1b[13;5u" send-keys C-CR
# # ctrl + return
# bind -n "\x1b[13;5u" send-keys C-CR
# # shift + return
# bind -T copy-mode-vi "\x1b[13;2u" send-keys S-CR
# # shift + return
# bind -n "\x1b[13;2u" send-keys S-CR
# Paired with keybindings.lua
# bind -n \{ if-shell "$is_vim" 'send-keys "[ "' 'send-keys \{'
# bind -n S-Enter send-keys '[ '
bind -n S-Enter send-keys '{'
# Vim/nvim leader key
unbind -n Space
# bind -n Space if-shell -F "#{@is-vim}" { send-keys Space } { next-window }
# bind -n S-Enter send-keys [-Space
# Does not work in tty, and works in GUI(foot/alacritty)
# C-[ is ESC. Don't do it!
# bind -n C-[ send-keys '[ '
# bind -n '[ ' send-keys S-Enter
# Paired with keybindings.lua
# bind -n \} if-shell "$is_vim" 'send-keys "] "' 'send-keys \}'
# bind -n C-Enter send-keys '] '
bind -n C-Enter send-keys '}'
# bind -n C-Enter send-keys ]-Space
# Does not work in tty, and works in GUI(foot/alacritty)
# bind -n C-] send-keys '] '
# bind -n '] ' send-keys C-Enter
%hidden use_bash=
%if "#{use_bash}"
set -ghu use_bash
%endif
# set-option -g @use-bash off
# [How to write if statement in .tmux.conf to set different options for different tmux versions?](https://stackoverflow.com/questions/35016458/how-to-write-if-statement-in-tmux-conf-to-set-different-options-for-different-t)
%if "#{use_bash}"
# if -b '[ "$(\tmux show -gqv '@use-bash')" = "on" ] && command -v /usr/bin/bash > /dev/null 2>&1' {
if-shell -b 'command -v /usr/bin/bash > /dev/null 2>&1' {
# if -b 'command -v /usr/bin/bash > /dev/null 2>&1' {
# %if '#(command -v /usr/bin/bash > /dev/null 2>&1)'
# %if "#{==:#(command -v /usr/bin/bash > /dev/null 2>&1 && echo "on" || echo ""),on}"
# has_bash='command -v /usr/bin/bash > /dev/null 2>&1 && echo "on" || echo ""'
# %if "#{==:#(if-shell -F "$has_bash" {echo "on"} {}),on}"
display -p "Has bash (it's not necessary). \"tmux-plugins\" applied on TERM: $TERM"
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin 'github_username/plugin_name'
# Other examples:
# smart pane switching with awareness of vim splits
# https://thoughtbot.com/blog/seamlessly-navigate-vim-and-tmux-splits
# # https://github.com/christoomey/vim-tmux-navigator
# /mnt/vinit/nvim/init.vim