-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
220 lines (197 loc) · 11.9 KB
/
.tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#############################
### PLUGINS CONFIGURATION ###
#############################
# Don't exit copy mode after copy
set -g @yank_action 'copy-pipe' # or 'copy-pipe-and-cancel' for the default
###############
### PLUGINS ###
###############
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
# Init TMUX plugin manager (https://github.com/tmux-plugins/tpm)
run '~/.tmux/plugins/tpm/tpm'
#####################
### CONFIGURATION ###
#####################
set -g mouse on # Enable mouse support
set -g history-limit 50000 # increase scrollback buffer size
setw -g mode-keys vi # vim keys in "copy mode"
set -g base-index 1 # Set the base index for windows to 1 instead of 0 (because this is the way numbers are placed on qwerty)
setw -g pane-base-index 1 # Set the base index for panes to 1 instead of 0 (because this is the way numbers are placed on qwerty)
set -g default-terminal "xterm-256color" # Colorized bash prompt
set -sg escape-time 0 # No delay for escape key press
set -g status-position top # I don't really have reasons for it. Just why not
set -g detach-on-destroy off # Attach to another session on shell exit
set -g renumber-windows on # Automatically reorder windows
setw -g aggressive-resize on # Resize window to the smallest client in case when both clients observer the same window
# Show status bar only if there are several windows
# if -F '#{==:#{session_windows},1}' { set -g status off } { set -g status on }
# set-hook -g window-linked "if -F '#{==:#{session_windows},1}' { set -g status off } { set -g status on }"
# set-hook -g window-unlinked "if -F '#{==:#{session_windows},1}' { set -g status off } { set -g status on }"
# set-hook -g client-session-changed "if -F '#{==:#{session_windows},1}' { set -g status off } { set -g status on }"
# window tabs in status bar
set -g window-status-current-style "bg=default,reverse"
set -g window-status-separator '│'
set -g allow-rename on # Allow shell escape sequence to control tmux window title
# enable activity alerts (changes window items in status bar when any activity happens on that window)
# TODO Fix monitor activity across sessions
# setw -g monitor-activity on
# set -g visual-activity on
# Send sigint to all panels TODO do I need it?
# bind X run-shell "tmux list-panes -s -F '##{pane_pid} ##{pane_current_command}' | grep -v tmux | awk '{print $1}' | xargs kill -INT"
################
### BINDINGS ###
################
unbind -a # Unbind all awful default keys
bind -n M-h if -F '#{pane_at_left}' 'previous-window' 'select-pane -L'
bind -n M-l if -F '#{pane_at_right}' 'next-window' 'select-pane -R'
bind -n M-k if -F '#{pane_at_top}' '' 'select-pane -U' # Disable wrapping
bind -n M-j if -F '#{pane_at_bottom}' '' 'select-pane -D' # Disable wrapping
# bind / split-window -h -c "#{pane_current_path}"
# bind - split-window -v -c "#{pane_current_path}"
# Cycle between even-horizontal/even-vertical
bind -r / if "[ $(echo '#{window_layout}' | sed s/[^\[\{]//g) = '[' ]" \
{ select-layout even-horizontal } { select-layout even-vertical }
# Cycle between main-vertical/main-horizontal
# bind -n , if "[ $(echo '#{window_layout}' | sed s/[^\[\{]//g) = '[{' ]" \
# {
# select-layout main-vertical
# # Hack to make main-vertical spread evenly horizontally
# select-layout -E main-vertical
# } \
# { select-layout main-horizontal }
# Split window and normalize layout
bind -n M-. run "
tmux split-window -c '#{pane_current_path}' -v
# you can use 'tmux display-message -p' instead of 'echo'
layout=$(echo '#{window_layout}' | sed s/[^\[\{]//g)
{ [ \$layout = '{' ] && tmux select-layout even-horizontal; } ||
{ [ \$layout = '[{' ] && tmux select-layout main-horizontal; } ||
# Hack to make main-vertical spread evenly horizontally
{ [ \$layout = '{[' ] && tmux select-layout main-vertical && tmux select-layout -E main-vertical; } ||
tmux select-layout even-vertical"
# TODO drop?
# bind , display-menu \
# even-Horizontal 'h' 'select-layout even-horizontal' \
# even-Vertical 'v' 'select-layout even-vertical' \
# main-hOrizontal 'o' 'select-layout main-horizontal' \
# main-vErtical 'e' 'select-layout main-vertical' \
# Tiled 't' 'select-layout tiled'
bind Enter new-window -c "#{pane_current_path}" -a
bind -n M-H if -F '#{pane_at_left}' \
{
if '[ #{pane_at_right} = 1 ] && [ #{pane_at_top} = 1 ] && [ #{pane_at_bottom} = 1 ]' \
{ join-pane -t :-1 } \
{ break-pane -b }
} \
{ select-pane -L; swap-pane -t ! } # ! is a previously active pane
bind -n M-L if -F '#{pane_at_right}' \
{
if '[ #{pane_at_left} = 1 ] && [ #{pane_at_top} = 1 ] && [ #{pane_at_bottom} = 1 ]' \
{ join-pane -t :+1 } \
{ break-pane -a }
} \
{ select-pane -R; swap-pane -t ! } # ! is a previously active pane
bind -n M-K if -F '#{pane_at_top}' '' { select-pane -U; swap-pane -t ! }
bind -n M-J if -F '#{pane_at_bottom}' '' { select-pane -D; swap-pane -t ! }
# Pane resizing (repetitive) panes with Prefix h,j,k,l
bind -r h resize-pane -L 1
bind -r j resize-pane -D 1
bind -r k resize-pane -U 1
bind -r l resize-pane -R 1
bind v copy-mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi i send -X cancel
bind -T copy-mode-vi 'C-q' send -X begin-selection\; send -X rectangle-toggle
bind -T copy-mode-vi p paste-buffer -p\; send -X cancel
# TODO fix Y
bind -r Tab switch -l
# Swap HL pair with ^$ pair (the same is done in my vim config)
bind -T copy-mode-vi H send -X back-to-indentation
bind -T copy-mode-vi L send -X end-of-line
bind -T copy-mode-vi ^ send -X top-line
bind -T copy-mode-vi \$ send -X bottom-line
bind -r < { swap-window -t -1; previous-window }
bind -r > { swap-window -t +1; next-window }
# Disable auto copy on mouse release https://github.com/tmux/tmux/issues/140
unbind -T copy-mode-vi MouseDragEnd1Pane
# since MouseDragEnd1Pane neither exit copy-mode nor clear selection now,
# let single click do selection clearing for us. https://github.com/tmux/tmux/issues/140
bind -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection
# Just visually select word/line and DON'T copy (by default tmux also copies which is not what I want)
# With help of https://www.seanh.cc/2020/12/27/copy-and-paste-in-tmux/ also related https://github.com/tmux/tmux/issues/140
bind -T copy-mode-vi DoubleClick1Pane select-pane\; send -X select-word
bind -n DoubleClick1Pane select-pane\; copy-mode -M\; send -X select-word
bind -n TripleClick1Pane select-pane\; copy-mode -M\; send -X select-line
bind -T copy-mode-vi TripleClick1Pane select-pane\; send -X select-line
# Incremental search
bind -T copy-mode-vi / command-prompt -i -p "(search down)" "send -X search-forward-incremental \"%%%\""
bind -T copy-mode-vi ? command-prompt -i -p "(search up)" "send -X search-backward-incremental \"%%%\""
# Switch or create new session
bind -n M-q if 'tmux switch -t QQQ' '' 'new-session -s QQQ'
bind -n M-w if 'tmux switch -t WWW' '' 'new-session -s WWW'
bind -n M-e if 'tmux switch -t EEE' '' 'new-session -s EEE'
bind -n M-r if 'tmux switch -t RRR' '' 'new-session -s RRR'
bind -n M-t if 'tmux switch -t TTT' '' 'new-session -s TTT'
bind -n M-y if 'tmux switch -t YYY' '' 'new-session -s YYY'
bind -n M-u if 'tmux switch -t UUU' '' 'new-session -s UUU'
bind -n M-i if 'tmux switch -t III' '' 'new-session -s III'
bind -n M-o if 'tmux switch -t OOO' '' 'new-session -s OOO'
bind -n M-p if 'tmux switch -t PPP' '' 'new-session -s PPP'
bind -n M-a if 'tmux switch -t AAA' '' 'new-session -s AAA'
bind -n M-s if 'tmux switch -t SSS' '' 'new-session -s SSS'
bind -n M-d if 'tmux switch -t DDD' '' 'new-session -s DDD'
bind -n M-f if 'tmux switch -t FFF' '' 'new-session -s FFF'
bind -n M-g if 'tmux switch -t GGG' '' 'new-session -s GGG'
bind -n M-z if 'tmux switch -t ZZZ' '' 'new-session -s ZZZ'
bind -n M-x if 'tmux switch -t XXX' '' 'new-session -s XXX'
bind -n M-c if 'tmux switch -t CCC' '' 'new-session -s CCC'
bind -n M-v if 'tmux switch -t VVV' '' 'new-session -s VVV'
bind -n M-b if 'tmux switch -t BBB' '' 'new-session -s BBB'
bind -n M-n if 'tmux switch -t NNN' '' 'new-session -s NNN'
bind -n M-m if 'tmux switch -t MMM' '' 'new-session -s MMM'
bind -n M-1 if 'tmux switch -t 111' '' 'new-session -s 111'
bind -n M-2 if 'tmux switch -t 222' '' 'new-session -s 222'
bind -n M-3 if 'tmux switch -t 333' '' 'new-session -s 333'
bind -n M-4 if 'tmux switch -t 444' '' 'new-session -s 444'
bind -n M-5 if 'tmux switch -t 555' '' 'new-session -s 555'
bind -n M-6 if 'tmux switch -t 666' '' 'new-session -s 666'
bind -n M-7 if 'tmux switch -t 777' '' 'new-session -s 777'
bind -n M-8 if 'tmux switch -t 888' '' 'new-session -s 888'
bind -n M-9 if 'tmux switch -t 999' '' 'new-session -s 999'
bind -n M-0 if 'tmux switch -t 000' '' 'new-session -s 000'
# Switch or create new session
bind -n M-'Q' if 'tmux break-pane -t QQQ:' '' { new-session -d -s QQQ exit; break-pane -t QQQ: }
bind -n M-'W' if 'tmux break-pane -t WWW:' '' { new-session -d -s WWW exit; break-pane -t WWW: }
bind -n M-'E' if 'tmux break-pane -t EEE:' '' { new-session -d -s EEE exit; break-pane -t EEE: }
bind -n M-'R' if 'tmux break-pane -t RRR:' '' { new-session -d -s RRR exit; break-pane -t RRR: }
bind -n M-'T' if 'tmux break-pane -t TTT:' '' { new-session -d -s TTT exit; break-pane -t TTT: }
bind -n M-'Y' if 'tmux break-pane -t YYY:' '' { new-session -d -s YYY exit; break-pane -t YYY: }
bind -n M-'U' if 'tmux break-pane -t UUU:' '' { new-session -d -s UUU exit; break-pane -t UUU: }
bind -n M-'I' if 'tmux break-pane -t III:' '' { new-session -d -s III exit; break-pane -t III: }
bind -n M-'O' if 'tmux break-pane -t OOO:' '' { new-session -d -s OOO exit; break-pane -t OOO: }
bind -n M-'P' if 'tmux break-pane -t PPP:' '' { new-session -d -s PPP exit; break-pane -t PPP: }
bind -n M-'A' if 'tmux break-pane -t AAA:' '' { new-session -d -s AAA exit; break-pane -t AAA: }
bind -n M-'S' if 'tmux break-pane -t SSS:' '' { new-session -d -s SSS exit; break-pane -t SSS: }
bind -n M-'D' if 'tmux break-pane -t DDD:' '' { new-session -d -s DDD exit; break-pane -t DDD: }
bind -n M-'F' if 'tmux break-pane -t FFF:' '' { new-session -d -s FFF exit; break-pane -t FFF: }
bind -n M-'G' if 'tmux break-pane -t GGG:' '' { new-session -d -s GGG exit; break-pane -t GGG: }
bind -n M-'Z' if 'tmux break-pane -t ZZZ:' '' { new-session -d -s ZZZ exit; break-pane -t ZZZ: }
bind -n M-'X' if 'tmux break-pane -t XXX:' '' { new-session -d -s XXX exit; break-pane -t XXX: }
bind -n M-'C' if 'tmux break-pane -t CCC:' '' { new-session -d -s CCC exit; break-pane -t CCC: }
bind -n M-'V' if 'tmux break-pane -t VVV:' '' { new-session -d -s VVV exit; break-pane -t VVV: }
bind -n M-'B' if 'tmux break-pane -t BBB:' '' { new-session -d -s BBB exit; break-pane -t BBB: }
bind -n M-'N' if 'tmux break-pane -t NNN:' '' { new-session -d -s NNN exit; break-pane -t NNN: }
bind -n M-'M' if 'tmux break-pane -t MMM:' '' { new-session -d -s MMM exit; break-pane -t MMM: }
bind -n M-'!' if 'tmux break-pane -t 111:' '' { new-session -d -s 111 exit; break-pane -t 111: }
bind -n M-'@' if 'tmux break-pane -t 222:' '' { new-session -d -s 222 exit; break-pane -t 222: }
bind -n M-'#' if 'tmux break-pane -t 333:' '' { new-session -d -s 333 exit; break-pane -t 333: }
bind -n M-'$' if 'tmux break-pane -t 444:' '' { new-session -d -s 444 exit; break-pane -t 444: }
bind -n M-'%' if 'tmux break-pane -t 555:' '' { new-session -d -s 555 exit; break-pane -t 555: }
bind -n M-'^' if 'tmux break-pane -t 666:' '' { new-session -d -s 666 exit; break-pane -t 666: }
bind -n M-'&' if 'tmux break-pane -t 777:' '' { new-session -d -s 777 exit; break-pane -t 777: }
bind -n M-'*' if 'tmux break-pane -t 888:' '' { new-session -d -s 888 exit; break-pane -t 888: }
bind -n M-'(' if 'tmux break-pane -t 999:' '' { new-session -d -s 999 exit; break-pane -t 999: }
bind -n M-')' if 'tmux break-pane -t 000:' '' { new-session -d -s 000 exit; break-pane -t 000: }
bind Space choose-tree -Z
bind : command-prompt