forked from evandrocoan/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
93 lines (77 loc) · 4.16 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
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
# https://stackoverflow.com/questions/11832199/tmux-set-g-mouse-mode-on-doesnt-work
setw -g mouse
set-option -g mouse on
set-option -g display-time 4000
set-option -g history-limit 99999
set-window-option -g mode-keys vi
# https://unix.stackexchange.com/questions/70598/tmux-showing-sessions-on-bottom-row
set -g status-left-length 80
set -g status-right-length 80
set -g status off
# https://www.reddit.com/r/tmux/comments/gthh70/how_to_show_vpn_ip_in_tmux_status_line/
set-option -g status-interval 30
set -g status-right "#{=22:pane_title} #(if [[ \"w\" == \"w$(ip &> /dev/null)\" ]]; then ipconfig | grep 'IPv4' | tail -1 | cut -f2 -d':' | xargs; else ip -4 -br a | grep UP | tail -1 | awk '{print $3}' | cut -f1 -d'/' | xargs; fi;) #(date +'%a %Y-%m-%d %R')"
# tmux select window with Alt<number> (i.e., allow to use numbers on keybindings)
# https://github.com/tmux/tmux/issues/2510
bind -n M-n select-window -n
bind -n M-p select-window -p
# https://unix.stackexchange.com/questions/35924/how-to-make-tmux-count-windows-starting-from-1-instead-of-0
set -g base-index 1
setw -g pane-base-index 1
bind -n M-0 select-window -t 10
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
# Option to disable "release mouse click to copy selection & exit copy-mode" behavior.
# https://github.com/tmux/tmux/issues/140
# disable "release mouse drag to copy and exit copy-mode", ref: https://github.com/tmux/tmux/issues/140
unbind-key -T copy-mode-vi MouseDragEnd1Pane
# since MouseDragEnd1Pane neither exit copy-mode nor clear selection now,
# let single click do selection clearing for us.
bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection
# https://superuser.com/questions/360832/how-can-i-make-ctrlleft-right-keys-to-move-by-whole-word-in-tmux
set-window-option -g xterm-keys on
run-shell ~/scripts/tmux-better-mouse-mode/scroll_copy_mode.tmux
run-shell ~/scripts/tmux-sensible/sensible.tmux
# https://andrewjamesjohnson.com/restoring-tmux-sessions
run-shell ~/scripts/tmux-resurrect/resurrect.tmux
set -g @resurrect-capture-pane-contents 'on'
# https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file
bind-key v 'capture-pane' \; run "tmux capture-pane -pJ -S- -E-|sed -E 's| *$||' >/tmp/tmux" \; display "Buffer saved to /tmp/tmux!" \;
# https://superuser.com/questions/231002/how-can-i-search-within-the-output-buffer-of-a-tmux-shell
# https://stackoverflow.com/questions/42202936/tmux-move-across-panels-with-vim-key-bindings-while-in-copy-mode
bind-key / copy-mode \; send-key ?
bind-key KP/ copy-mode \; send-key ?
bind-key -T copy-mode-vi / copy-mode \; send-key ?
bind-key -T copy-mode-vi KP/ copy-mode \; send-key ?
# Also, change some visual styles when window keys are off
# https://www.freecodecamp.org/news/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795/
# https://github.com/samoshkin/tmux-config/blob/master/tmux/tmux.conf
bind -T root C-F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=colour245,bg=colour238" \;\
set window-status-current-format "#[fg=colour238,bg=colour254]#[default] #I:#W# #[fg=colour254,bg=colour238]#[default]" \;\
set window-status-current-style "fg=colour232,bold,bg=colour254" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
display-message "Disabling tmux input" \;
bind -T off C-F12 \
set -u prefix \;\
set -u key-table \;\
set -u status-style \;\
set -u window-status-current-style \;\
set -u window-status-current-format \;\
refresh-client -S \;\
display-message "Disabling tmux input" \;
# https://superuser.com/questions/238545/binding-a-command-in-tmux-without-using-the-prefix-key
# https://stackoverflow.com/questions/25909964/tmux-how-to-toggle-on-and-off-options-with-the-same-key
bind-key -n F12 set-window-option status