-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
293 lines (234 loc) · 10.3 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
# set-option -g default-shell /bin/zsh
set-option -g update-environment "SSH_AUTH_SOCK \
SSH_CONNECTION \
DISPLAY \
VSCODE_IPC_HOOK_CLI \
PATH"
set-option -g default-terminal screen-256color
# History
set -g history-limit 100000
# Window numbers from 1, not from 0, renumber if closed
set -g base-index 1
set-option -g renumber-windows on
# Quick Escape (for vim)
set -s escape-time 0
# Hotkeys using Alt/Option as a modifier
bind-key -n M-n new-window -c "#{pane_current_path}"
bind-key -n M-1 select-window -t :1
bind-key -n M-2 select-window -t :2
bind-key -n M-3 select-window -t :3
bind-key -n M-4 select-window -t :4
bind-key -n M-5 select-window -t :5
bind-key -n M-6 select-window -t :6
bind-key -n M-7 select-window -t :7
bind-key -n M-8 select-window -t :8
bind-key -n M-9 select-window -t :9
bind-key -n M-0 select-window -t :0
bind-key -n M-. select-window -n
bind-key -n M-, select-window -p
bind-key -n M-< swap-window -t -1
bind-key -n M-> swap-window -t +1
bind-key -n M-X confirm-before "kill-window"
bind-key -n M-R command-prompt -I "#W" "rename-window '%%'"
bind-key -n M-f resize-pane -Z
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
bind-key -n M-k select-pane -U
bind-key -n M-j select-pane -D
bind-key -n M-Left select-pane -L
bind-key -n M-Right select-pane -R
bind-key -n M-Up select-pane -U
bind-key -n M-Down select-pane -D
bind-key -n "M-H" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
bind-key -n "M-J" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
bind-key -n "M-K" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
bind-key -n "M-L" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
bind-key -n "M-S-Left" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -L; tmux swap-pane -t $old'
bind-key -n "M-S-Down" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -D; tmux swap-pane -t $old'
bind-key -n "M-S-Up" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -U; tmux swap-pane -t $old'
bind-key -n "M-S-Right" run-shell 'old=`tmux display -p "#{pane_index}"`; tmux select-pane -R; tmux swap-pane -t $old'
bind-key -n M-x confirm-before "kill-pane"
#bind-key -n M-/ copy-mode
bind-key -n M-/ copy-mode \; command-prompt -p "(search up)" "send -X search-backward \"%%%\""
# linux system clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xsel -i -b'
# macOS system clipboard
#bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
#bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"
set -g status-keys emacs
set -g focus-events on
setw -g aggressive-resize on
set -g mouse on
set-option -g set-titles on
set-option -g set-titles-string 'tmux - #W'
set -g bell-action any
set-option -g visual-bell off
set-option -g set-clipboard off
setw -g mode-keys vi
setw -g monitor-activity on
# Notifications
set -g visual-activity off
# Don't wrap searches; it's super confusing given tmux's reverse-ordering of
# position info in copy mode.
set-option -w -g wrap-search off
# Personal
set -g status-bg default
set -g status-fg green
set-option -g repeat-time 0
set -sg escape-time 0
#set -g default-terminal "screen-256color"
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",alacritty:Tc"
# mouse settings
set -g mouse on
unbind-key -T copy-mode-vi MouseDragEnd1Pane
# Add : to the default list (" -_@") of word separators.
set-option -ga word-separators :/
# Scroll 3 lines at a time instead of default 5; don't extend dragged selections.
bind-key -T copy-mode-vi WheelUpPane select-pane\; send-keys -t'{mouse}' -X clear-selection\; send-keys -t'{mouse}' -X -N 3 scroll-up
bind-key -T copy-mode-vi WheelDownPane select-pane\; send-keys -t'{mouse}' -X clear-selection\; send-keys -t'{mouse}' -X -N 3 scroll-down
# Make double and triple click work outside of copy mode (already works inside it with default bindings).
bind-key -T root DoubleClick1Pane if-shell -Ft'{mouse}' '#{alternate_on}' "send-keys -M" "copy-mode -t'{mouse}'; send-keys -t'{mouse}' -X select-word"
bind-key -T root TripleClick1Pane if-shell -Ft'{mouse}' '#{alternate_on}' "send-keys -M" "copy-mode -t'{mouse}'; send-keys -t'{mouse}' -X select-line"
# Don't exit copy mode on double or triple click.
bind-key -T copy-mode-vi DoubleClick1Pane if-shell -Ft'{mouse}' '#{alternate_on}' "send-keys -M" "copy-mode -t'{mouse}'; send-keys -t'{mouse}' -X select-word"
bind-key -T copy-mode-vi TripleClick1Pane if-shell -Ft'{mouse}' '#{alternate_on}' "send-keys -M" "copy-mode -t'{mouse}'; send-keys -t'{mouse}' -X select-line"
# For those times when C-c and q are not enough.
bind-key -T copy-mode-vi Escape send-keys -X cancel
bind m set-option mouse\; display-message "Mouse is now #{?mouse,on,off}"
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
bind \; command-prompt "swap-pane -t '%%'"
bind S choose-tree "swap-pane -s "%%""
#remap C-b to C-t
unbind C-b
bind C-b command-prompt "setw synchronize-panes '%%'"
set-option -g prefix C-t
bind-key C-t send-prefix
# vim keys
set-window-option -g mode-keys vi
# better window numbering
set -g base-index 1
set -g renumber-windows on
bind -Tcopy-mode-vi v send -X begin-selection
#bind -Tcopy-mode-vi y send -X copy-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-no-clear 'xsel -i -b'
bind -T copy-mode-vi C-c send-keys -X copy-pipe-no-clear 'xsel -i -b'
bind -T copy-mode-vi C-x send-keys -X copy-pipe 'xsel -i -b'
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L"
bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D"
bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U"
bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R"
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-key -T copy-mode-vi M-h select-pane -L
bind-key -T copy-mode-vi M-j select-pane -D
bind-key -T copy-mode-vi M-k select-pane -U
bind-key -T copy-mode-vi M-l select-pane -R
# Use Alt-arrow keys without prefix key to switch panes
bind-key -n M-Left select-pane -L
bind-key -n M-Right select-pane -R
bind-key -n M-Up select-pane -U
bind-key -n M-Down select-pane -D
# vim-like pane switching
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
bind-key v split-window -h -c "#{pane_current_path}"
bind-key s split-window -v -c "#{pane_current_path}"
bind-key C-S choose-session
bind-key C-X confirm-before -p "Kill #S (y/n)?" "run-shell 'tmux switch-client -n \\\; kill-session -t \"\$(tmux display-message -p \"#S\")\"'"
# split in current dir
unbind %
bind % split-window -h -c "#{pane_current_path}"
unbind c
bind c new-window -c "#{pane_current_path}"
unbind C-c
bind C-c new-window -c "#{pane_current_path}"
# close panes
unbind C-w
bind C-w kill-pane
# close sessions with q
unbind q
bind q confirm kill-session
# close server with ctrl-q
unbind C-q
bind C-q confirm kill-server
set -g display-panes-time 2000
bind g display-pane
# multicast
## bind -r b setw synchronize-panes on
## bind -r B setw synchronize-panes off
# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
# be sure to see note* below
# Avoid date/time taking up space
set -g status-left '#{?client_prefix,#[fg=blue],}[#S] #(hostname)'
set -g status-right ''
set -g status-right-length 0
set -g window-status-format ' #I #W '
# set -g window-status-format ' #I #W:#(pwd="#{pane_current_path}"; basename ${pwd####*/}) '
set -g window-status-current-format ' #{?client_prefix,#[fg=blue],}[#I #{?pane_synchronized,#[fg=blue](SYNC)#[default],}#{?window_zoomed_flag,*,}#W#{?window_zoomed_flag,*,}]'
#set -g window-status-current-format " [#W]"
#set -g window-status-format " #W "
set -g status-left-length 100
set -g status-justify right
# status bar updates every 15s by default**, change to 1s here
# (this step is optional - a lower latency might have negative battery/cpu usage impacts)
set -g status-interval 5
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off 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
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]"
# set -g status-right $wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host"
# PLUGINS
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
set -g @plugin 'fcsonline/tmux-thumbs'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# yank to clipboard
set -g @plugin 'tmux-plugins/tmux-yank'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
unbind-key -T copy-mode-vi MouseDragEnd1Pane