-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
314 lines (286 loc) · 12.8 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
# Local config {{{
if-shell "[ -f ~/.tmux.conf.user ]" 'source ~/.tmux.conf.user'
# Local config }}}
# Terminal type configuration {{{
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
# set -g default-terminal screen-256color
if-shell "uname | grep -i cygwin" 'set-environment -g pastecmd "putclip" ; set-environment -g copycmd "getclip"' \
'set-environment -g pastecmd "pbpaste" ; set-environment -g copycmd "pbcopy"'
# if-shell true "display 'test' ; myvar=1"
# if-shell "uname | grep -i cygwin" "pastecmd=putclip ; b=a1" "pastecmd=pbpaste \; b=a2"
# if-shell "uname | grep -i cygwin" copycmd="getclip" copycmd="pbcopy"
# if-shell true {display {test} ; myvar=1}
# Terminal type configuration }}}
#Status {{{
#Aliases: Windows flags(#F) , Window Index(#I), Window name(#W)
set -g status-right '#{prefix_highlight} | #W | %a %Y-%m-%d %H:%M'
set -g status-left '#[fg=colour235,bg=colour252,bold] P:#{window_panes} ❐ #W #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold]#[fg=colour238,bg=colour234,nobold]⮀'
#set status-left-length 40
setw -g window-status-format '#[fg=colour235,bg=colour252,bold]#F #I #{pane_current_command}'
setw -g window-status-format '#[fg=colour238,bg=colour252]⮀#[fg=colour235,bg=colour252,bold]#F#I #{=-8:window_name} #{?#{!=:#{pane_current_command},zsh},#{pane_current_command},}#[fg=colour252,bg=colour238,nobold]⮀'
set -g window-status-current-format '#[fg=colour238,bg=colour39]⮀#[fg=black,bg=colour39,noreverse,bold]#F#I #{=-8:window_name} #{pane_current_command} #[fg=colour39,bg=colour234,nobold]⮀'
set -g status-left-length 32
set -g status-right-length 51
set -g window-status-separator ''
#Status }}}
#second status {{{
is_tmux3="tmux -V | sed 's/tmux //' | grep 3 "
if-shell "$is_tmux3" \
"set -g status 2 \; \
set-option -g status-format[1] \"#[fg=colour243,bg=colour237,none,fill=colour237]#[align=centre]#{pane_current_path}#[fg=white,align=right]#(tmux show-buffer|cut -c -35|sed 's/#/##/g')\""
# set-option -g status-format[1] \"#[fg=colour243,bg=colour237,none,fill=colour237]#[align=centre]#{pane_current_path}#[fg=white,align=right]mouse:#{mouse_any_flag}❐pane:#{pane_in_mode}❐#(tmux show-buffer|cut -c -35|sed 's/#/##/g')\""
#second status }}}
#colors {{{
set -g status-fg white
set -g status-style bg=colour234
set -g window-status-activity-style bold
set -g pane-border-style fg=colour245
set -g pane-active-border-style fg=colour39
set -g message-style fg=colour16
set -g message-style bg=colour221
set -g message-style bold
#colors }}}
#settings {{{
# Ring the bell if any background window rang a bell
set -g bell-action any
set -g monitor-activity on
set -g monitor-bell on
set -g assume-paste-time 0
setw -g word-separators ' @"=()[]'
set -g allow-rename on
set -g repeat-time 300
set -g set-titles on
set-option -g status-interval 2
# Patch for OS X pbpaste and pbcopy under tmux - Deprecated - using tmux-yank
#set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL"
# No escape time for vi mode
set -sg escape-time 0
# Bigger history
set -g history-limit 1000000
set -g renumber-windows on
set -g mouse on
set -g history-file ~/.tmux-history
set -g status-keys vi
#Renumber windows to 1 instead of 0
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-window-option -g mouse on
#settings }}}
#Bindings{{{
#change prefix {{{
unbind C-b
set -g prefix C-a
bind a send-prefix
#Switch prefix in case we want to use C-a for remote tmux session
bind C-b if-shell 'tmux show-options -vg prefix | grep "C-a"' \
"set -g prefix C-b \; display 'Prefix is C-b'" \
"set -g prefix C-a \; display 'Prefix is C-a'"
#change prefix }}}
bind c new-window -c "#{pane_current_path}"
bind ^D detach-client
bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind C-a last-window
#bind pageup to scroll
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'
bind -Troot PageUp if-shell "$is_vim" "send-keys Pageup" "select-pane ; copy-mode ; send-keys -X page-up"
#bind shift pageup for scrolling in pager apps
bind -n s-PageUp send-keys PageUp
#Kill stuff
bind x confirm-before -p "Kill window? [y/n] " kill-pane
bind C-q confirm-before -p "Kill session? [y/n] " kill-session
bind C-Q kill-session
# bind -n C-j last-pane
# bind -n M-l last-pane
#faster copy mode
bind q copy-mode
bind w paste-buffer
#bind m to Enable/Disable mouse
bind m if-shell 'tmux show-options -vg mouse | grep on' \
"set -g mouse off \; display \"Mouse is OFF\"" \
"set -g mouse on \; display 'Mouse is ON'"
#buffers
bind P choose-buffer # choose which buffer to paste from
#vi mode search
bind-key -T copy-mode-vi ? command-prompt -i -p "search up" "send -X search-backward-incremental \"%%%\""
#open manual in split
# bind ? command-prompt "split-window -h 'exec man %%'"
# Create splits and vertical splits {{{
bind | split-window -h -p 30 -c "#{pane_current_path}"
bind ^V split-window -h -p 50 -c "#{pane_current_path}"
bind s split-window -p 50 -c "#{pane_current_path}"
bind _ split-window -p 30 -c "#{pane_current_path}"
# Create splits and vertical splits }}}
# Pane resize in all four directions using vi bindings. {{{
# Can use these raw but I map them to shift-ctrl-<h,j,k,l> in iTerm.
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Pane resize in all four directions using vi bindings. }}}
# Smart pane switching with awareness of vim splits {{{
# Source: https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
# Smart pane switching with awareness of vim splits }}}
# swap windows wit CTRL+SHIFT+arrows {{{
bind-key -n C-S-Left if-shell "$is_vim" "send-keys C-S-Left" "swap-window -d -t-1"
bind-key -n C-S-Right if-shell "$is_vim" "send-keys C-S-Right" "swap-window -d -t+1"
# swap windows wit CTRL+SHIFT+arrows }}}
# easily toggle synchronization (mnemonic: e is for echo) {{{
# sends input to all panes in a given window.
bind e setw synchronize-panes on \; display 'synchronize panes is on'
bind E setw synchronize-panes off \; display 'synchronize panes is off'
# easily toggle synchronization (mnemonic: e is for echo) }}}
#Bind to free window with speific name, if on active window, go to next {{{
get_window="tmux list-windows -F '##{window_index} ##{pane_current_command} ##{window_name} ##{window_active}' | grep -i -- \"$(tmux show-option -vg @progname)\" "
get_available_window="$get_window | grep -v '1$' | awk '{print $1}' | tail -1 | xargs tmux select-window -t"
isactive="$get_window| grep '1$' "
getnext="$get_window| awk 'NR==1 {firstline=$0} ;/1$/ { if (getline==0) {print firstline} else {print $0}}' | awk '{print $1}' | xargs tmux select-window -t"
bind C-x set -g @progname 'zsh -' \; \
if-shell "$isactive" 'run "$getnext"' 'run "$get_available_window"'
#Bind to window containing vrc command
bind C-v set -g @progname vrc \; \
if-shell "$isactive" 'run "$getnext"' 'run "$get_available_window"'
#Bind to window containing ssh command
bind C-s set -g @progname ssh \; \
if-shell "$isactive" 'run "$getnext"' 'run "$get_available_window"'
#Bind to window containing man command
bind C-m set -g @progname man \; \
if-shell "$isactive" 'run "$getnext"' 'run "$get_available_window"'
# #Bind to window containing man command
bind v set -g @progname vim \; \
if-shell "$isactive" 'run "$getnext"' 'run "$get_available_window"'
#Bind to free window with speific name, if on active window, go to next }}}
#execute command in clipboard on new pane {{{
is_only_window="tmux list-windows -t aviasd -F '##{window_panes} ##{window_active}' | grep '1$' | cut -f1 -d\\ | grep 1"
suffix_commands="paste-buffer \; send-key Enter \; last-pane"
bind c-e run '$pastecmd | tmux loadb -' \; \
if-shell "$is_only_window" \
"split-window -p 30 -c '#{pane_current_path}' \; run 'sleep 1' \; $suffix_commands" \
"last-pane \; $suffix_commands"
#execute command in clipboard on new pane }}}
#Bindings}}}
#meta bindings {{{
#Switch to main window and zoom toogle
is_zoomed='echo "#{window_zoomed_flag}" | grep -q "1"'
bind -n M-z if-shell "$is_zoomed" "last-pane" "select-pane -t:.1 \; resize-pane -Z"
bind -n M-x previous-window
bind -n M-c next-window
bind -n M-v last-window
bind -n M-Left prev
bind -n M-Right next
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Shift arrow to switch windows {{{
bind -n M-S-Left select-pane -L
bind -n M-S-Right select-pane -R
# Shift arrow to switch windows }}}
#meta bindings }}}
#MACROS table bindings {{{
bind-key -Troot M-a switch-client -Tmacros
bind -Tmacros z if-shell "$is_zoomed" "last-pane \; resize-pane -Z" "select-pane -t:.1 \; resize-pane -Z"
bind-key -Tmacros c list-keys -Tmacros
bind-key -Tmacros c-s send-keys c-s
#MACROS table bindings }}}
# MOUSE BINDING {{{
if-shell $is_tmux3 "bind-key -n DoubleClick1StatusRight command-prompt"
bind-key -n MouseDrag1Status swap-window -t=
#new window on right click status
bind -n MouseDown3Status new-window -a -t=
#double click status to close window
bind -n DoubleClick1Status kill-window -t=
#right click paste
bind-key -n MouseDown3Pane run '$pastecmd | tmux loadb -' \; paste-buffer
bind-key -n S-MouseDown3Pane paste-buffer
# MOUSE BINDING }}}
#copy mode binding {{{
#escape mode with escape
bind -T copy-mode-vi Escape send-keys -X cancel
#don't select new line on $
bind -T copy-mode-vi "\$" \
send-keys -X end-of-line \; \
send-keys -X cursor-left \; \
#Open google search on selection
bind -T copy-mode-vi "d" send-keys -X copy-pipe-and-cancel "xargs -I{} open 'https://www.google.com/search?q='\"{}\""
#ripgrep selection
bind -T copy-mode-vi "g" \
send-keys -X copy-selection-and-cancel \; \
send-keys "rg -w " \; \
pasteb \; \
send-keys Enter
#open selection in vim
bind -T copy-mode-vi "v" \
send-keys -X copy-selection-and-cancel \; \
send-keys "vi " \; \
send-keys Enter \; \
send-keys i \; \
pasteb \; \
send-keys Escape
#yank line
bind -T copy-mode-vi "#" \
select-pane \; \
send-keys -X begin-selection \; \
send-keys -X end-of-line \; \
send-keys -X cursor-left \; \
# send-keys -X copy-selection-and-cancel
#vi mode mouse bindings
bind -T copy-mode-vi MouseDown3Pane \
select-pane \; \
send-keys -X copy-selection-and-cancel
#double click to copy a WORD
bind -T copy-mode-vi DoubleClick1Pane \
select-pane \; \
send-keys -X select-word \; \
send-keys -X copy-pipe "$copycmd"
bind -n DoubleClick1Pane \
select-pane \; \
copy-mode \; \
send-keys -X select-word \; \
send-keys -X copy-pipe-and-cancel "$copycmd" \; \
display-message "Copied to clip..."
#Triple click to select whole line
bind -n TripleClick1Pane \
select-pane \; \
copy-mode \; \
send-keys -X select-line \; \
send-keys -X copy-pipe-and-cancel "$copycmd" \; \
display-message "Copied line to clip..."
#Scroll through previous prompts
bind -T copy-mode-vi S-Up send -X search-backward "" \; send -X search-again
#copy mode binding }}}
#Hooks - Deperacted - using tmux-zorder-menu - unused {{{
#set-hook -g after-select-window "run ~/tmux_session.zsh"
#run "tmux list-windows -F '##{window_index} ##{window_active}' | awk '$2==1 {print $1}'| xargs tmux set -g @zorder"
#Bind zorder
#bind s "run-shell '~/tmux_session.zsh zorder_show_menu'"
#Hooks - Deperacted - using tmux-zorder-menu - unused }}}
# List of plugins {{{
set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'avielsh/tmux-zorder-menu'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-urlview'
# List of plugins }}}
#Plugin config {{{
set -g @resurrect-strategy-vim 'session'
set -g @prefix_highlight_output_prefix '⌨️ ' #keyboard
set -g @prefix_highlight_show_copy_mode 'on'
set -g @crefix_highlight_copy_mode_attr 'fg=black,bg=blue,bold' # default is 'fg=default,bg=yellow'
set -g @prefix_highlight_copy_prompt '🍀'
#tmux-zorder-menu
# set -g @zorder_window_info_format '#{window_name} #{pane_current_command} - #T #[fg=blue,bg=default,bold,align=right]#{pane_current_path}'
set -g @zorder_window_info_format '#{window_name} : #{pane_current_command} #[fg=blue,bg=default,bold,align=right]#{pane_current_path}'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]/user/plugin'
# set -g @plugin '[email protected]/user/plugin'
#Plugin config }}}
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'