-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
461 lines (392 loc) · 15.7 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
# cat << ►_◄ > /dev/null
###########################################################################
# General options
# ^F is easier to press
unbind C-b
set -g prefix C-f
bind C-f send-prefix
# Keep mouse on (since it works with OSX, iTerm)
set -g mouse on
# Disable paste-time for iTerm2 hex key code compatability
set -g assume-paste-time 0
# colors!
# Default terminal is 256 colors
# set -g default-terminal "screen-256color"
# Add truecolor support
# set-option -ga terminal-overrides ",xterm-256color:Tc"
# v2?
set -g default-terminal "xterm-256color"
# enable 24 bit support
set -g terminal-overrides ',xterm-256color:Tc'
setw -g xterm-keys on
# fastest command sequences
set -s escape-time 0
# increase repeat timeout
set -sg repeat-time 600
# focus events enabled for terminals that support them
set-option -g focus-events on
# super useful when using "grouped sessions" and multi-monitor setup
#set-window-option -g aggressive-resize on
# expect UTF-8
# broken with tmux 2.4?
# setw -g utf8 on
# set -g status-utf8 on
# Watch for activity in background windows
setw -g monitor-activity on
set -g visual-activity off
# increase scrollback size
set -g history-limit 50000
# Allow native OSX things to work properly; https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
if 'which -s reattach-to-user-namespace' 'set -g default-command "reattach-to-user-namespace $SHELL -l"'
# Always copy to OSX pasteboard
# Not needed after oSX 10.10?
if 'which -s reattach-to-user-namespace' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# Toggle status line
bind T set-option -g status
# edit configuration
bind e new-window -n '~/.tmux.conf' '${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"'
# reload configuration
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
# set-option remain-on-exit on
bind R split-window 'zsh -c "source ~/.bash_local && tmuxp-restart"'
# Move window left/right like browser
# https://www.seanh.cc/2020/12/30/how-to-make-tmux's-windows-behave-like-browser-tabs/
bind -n C-S-Left swap-window -t -1\; select-window -t -1
bind -n C-S-Right swap-window -t +1\; select-window -t +1
# -- display -------------------------------------------------------------------
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
# rename window to reflect current program
# set -g automatic-rename off
# renumber windows when a window is closed
set -g renumber-windows on
# set terminal title
set -g set-titles on
set -g set-titles-string '#h ❐ #S ● #I #W'
# slightly longer pane indicators display time
set -g display-panes-time 1000
# longer (2s) status messages display time
set -g display-time 2000
# redraw status line every 5 seconds
set -g status-interval 5
# 24 hour clock
setw -g clock-mode-style 24
# clear both screen and history
bind -n C-l send-keys C-l \; run 'tmux clear-history'
# tmux theme, colors and status line
# available themes:
# - powerline (a powerline inspired theme)
# - powerline_patched_font (a powerline inspired theme using a patched font)
tmux_conf_theme=powerline
# -- navigation ----------------------------------------------------------------
# override new-window, to be next to current window
bind c new-window -a
# create new session
bind C-c new-session
# find session
# bind C-f command-prompt -p find-session 'switch-client -t %%'
# split current window vertically, retain current path
bind '"' split-window -h -c "#{pane_current_path}"
bind _ split-window -h -c "#{pane_current_path}"
# split current window horizontally, retain current path
unbind %
bind % split-window -v -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# pane navigation
bind -r h select-pane -L # move left
bind -r j select-pane -D # move down
bind -r k select-pane -U # move up
bind -r l select-pane -R # move right
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
# maximize current pane
bind + run 'cut -c3- ~/.tmux.conf | sh -s maximize_pane'
# pane resizing
# bind -r H resize-pane -L 2
# bind -r J resize-pane -D 2
# bind -r K resize-pane -U 2
# bind -r L resize-pane -R 2
# window navigation
bind-key C-h previous-window # select previous window
bind-key C-l next-window # select next window
# bind-key Space last-session # move to last session
# toggle mouse
bind m run "cut -c3- ~/.tmux.conf | sh -s toggle_mouse"
# Swap sessions
bind-key s switch-client -n
# -- copy mode -----------------------------------------------------------------
# Fix Tmux 2.1 mouse scrolling
# 2023 - not needed anymore??
# bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
bind Enter copy-mode # enter copy mode
bind b list-buffers # list paster buffers
bind p paste-buffer # paste from the top pate buffer
bind P choose-buffer # choose which buffer to paste from
# vim style copy bindings https://github.com/gpakosz/.vim.git
# 2018-11-11 disabled in tmux 2.8?
#bind -t vi-copy v begin-selection
#bind -t vi-copy C-v rectangle-toggle
#bind -t vi-copy y copy-pipe "pbcopy"
#bind -t vi-copy Enter copy-pipe "pbcopy"
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind-key -T copy-mode-vi c-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection -x
#bind-key -T copy-mode-vi Y send-keys -X copy-end-of-line
#### # bind -t vi-copy Escape cancel
#bind -t vi-copy H start-of-line
#bind -t vi-copy L end-of-line
# -- user defined --------------------------------------------------------------
if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
# -- 8< ------------------------------------------------------------------------
run 'cut -c3- ~/.tmux.conf | sh -s apply_theme $tmux_conf_theme'
run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $name; done;'
# List of plugins
# Press prefix + I (capital I, as in Install) to fetch the plugin.
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set-option -g @sessionist-alternate "g"
set-option -g @sessionist-goto "G"
# Easy open
# prefix + o - open "thing"
# set -g @plugin 'tmux-plugins/tmux-open'
# Easy urlopen
# prefix + u - show any URLs
# using my fork for urlscan support + original fork mostly dead
# https://github.com/askedrelic/tmux-urlview
set -g @plugin 'askedrelic/tmux-urlview'
# Plugin that highlights when you press tmux prefix key
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr 'fg=black,bg=green,bold' # default is 'fg=default,bg=yellow'
# 1. Toggles (start/stop) logging in the current pane.
# Key binding: prefix + shift + p
# 2. Screen Capture
# Key binding: prefix + alt + p
# 3. Save complete history
# Key binding: prefix + alt + shift + p
set -g @plugin 'tmux-plugins/tmux-logging'
# remove toggle logging bind
unbind-key -T prefix P
run 'tmux bind-key -T prefix P $(tmux list-keys -T prefix M-p | grep -o "run-shell.*")'
# https://github.com/tmux-plugins/tmux-copycat
# prefix + ctrl-f - simple file search
# prefix + ctrl-g - jumping over git status files (best used after git status command)
# prefix + alt-h - jumping over SHA-1 hashes (best used after git log command)
# prefix + ctrl-u - url search (http, ftp and git urls)
# prefix + ctrl-d - number search (mnemonic d, as digit)
# prefix + alt-i - ip address search
# Currently disabled due to bug? https://github.com/tmux/tmux/issues/362
# set -g @plugin 'tmux-plugins/tmux-copycat'
# Easy paste bindings
# prefix + y - copies text from the command line to clipboard
# prefix + Y - copy pane current working directory to clipboard
# set -g @plugin 'tmux-plugins/tmux-yank'
# # other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]/user/plugin'
# # set -g @plugin '[email protected]/user/plugin'
# https://github.com/tmux-plugins/tmux-fpp
# set -g @plugin 'jbnicolai/tmux-fpp'
# Better copy pasta plugin?
# https://github.com/laktak/extrakto
set -g @plugin 'laktak/extrakto'
# Tab complete plugin.
# REQUIRES rust lol
# https://github.com/fcsonline/tmux-thumbs
set -g @plugin 'fcsonline/tmux-thumbs'
set -g @thumbs-command 'tmux set-buffer -- {} && tmux paste-buffer && echo -n {} | pbcopy'
# # Initialize TMUX plugin manager (keep this line at the very bottom of
# tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# ►_◄
# # exit the script if any statement returns a non-true return value
# set -e
#
# apply_theme() {
# case "$1" in
# powerline_patched_font)
# left_separator=''
# left_separator_black=''
# right_separator=''
# right_separator_black=''
# session_symbol=''
# ;;
# powerline)
# left_separator='|'
# left_separator_black=' '
# right_separator='|'
# right_separator_black=' '
# ;;
# esac
#
# case "$1" in
# powerline*)
#
# # panes
# pane_border_fg=colour238 # light gray
# pane_active_border_fg=colour39 # light blue
#
# tmux set -g pane-border-style fg=$pane_border_fg \; set -g pane-active-border-style fg=$pane_active_border_fg
# #uncomment for fat borders
# #tmux set -ga pane-border-style bg=$pane_border_fg \; set -ga pane-active-border-style bg=$pane_active_border_fg
#
# display_panes_active_colour=colour39 # light blue
# display_panes_colour=colour39 # light blue
# tmux set -g display-panes-active-colour $display_panes_active_colour \; set -g display-panes-colour $display_panes_colour
#
# # messages
# message_fg=colour16 #black
# message_bg=colour226 #yellow
# message_attr=bold
# tmux set -g message-style fg=$message_fg,bg=$message_bg,$message_attr
#
# # windows mode
# mode_fg=colour16 #black
# mode_bg=colour226 #yellow
# mode_attr=bold
# tmux setw -g mode-style fg=$mode_fg,bg=$mode_bg,$mode_attr
#
# # status line
# status_fg=colour253 # white
# status_bg=colour232 # dark gray
# tmux set -g status-style fg=$status_fg,bg=$status_bg
#
# # current session colors...
# session_fg=colour16 # black
# session_bg=colour226 # yellow
# status_left="#[fg=$session_fg,bg=$session_bg,bold] #S > #[fg=$session_bg,bg=$status_bg,nobold] #{prefix_highlight} $left_separator_black"
# tmux set -g status-left-length 32 \; set -g status-left "$status_left"
#
# window_status_fg=colour245 # light gray
# window_status_bg=colour232 # dark gray
# window_status_format="#I #W"
# tmux setw -g window-status-style fg="$window_status_fg",bg="$window_status_bg" \; setw -g window-status-format "$window_status_format"
#
# window_status_current_fg=colour16 # black
# window_status_current_bg=colour39 # light blue
# window_status_current_format="#[fg=$window_status_bg,bg=$window_status_current_bg]$left_separator_black#[fg=$window_status_current_fg,bg=$window_status_current_bg,bold] #I $left_separator #W #[fg=$window_status_current_bg,bg=$status_bg,nobold]$left_separator_black"
# tmux setw -g window-status-current-format "$window_status_current_format"
# tmux set -g status-justify centre
#
# window_status_activity_fg=default
# window_status_activity_bg=default
# window_status_activity_attr=underscore
# tmux setw -g window-status-activity-style fg=$window_status_activity_fg,bg=$window_status_activity_bg,$window_status_activity_attr
#
# time_date_fg=colour245 # light gray
# time_date_bg=colour232 # dark gray
# whoami_fg=colour254 # white
# whoami_bg=colour160 # red
# host_fg=colour16 # black
# host_bg=colour254 # white
# status_right=" #[fg=$whoami_fg,bg=$whoami_bg,nobold] #(whoami) $right_separator_black"
# tmux set -g status-right-length 64 \; set -g status-right "$status_right"
#
# # DISABLED clock
# # clock_mode_colour=colour39 # light blue
# # tmux setw -g clock-mode-colour $clock_mode_colour
# ;;
# esac
# }
#
# circled_digit() {
# circled_digits='⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳'
# if [ $1 -lt 20 ] 2>/dev/null ; then
# echo ${circled_digits:$1:1}
# else
# echo $1
# fi
# }
#
# maximize_pane() {
# tmux -q -L swap-pane-test -f /dev/null new-session -d \; new-window \; new-window \; swap-pane -t :1 \; kill-session || { tmux display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e'; exit; }
# __current_pane=$(tmux display -p '#{pane_id}')
#
# __dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_title}' | grep -o '^1 %.\+%.\+$' || true)
# __restore=$(echo "${__dead_panes}" | sed -n -E -e "s/^1 ${__current_pane} \[\+\](%[0-9]+)$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t ${__current_pane}/p" -e "s/^1 (%[0-9]+) \[\+\]${__current_pane}$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t \1/p" )
#
# if [ x"${__restore}" = x ] ; then
# [ x"$(tmux list-panes | wc -l | sed 's/^ *//g')" = x1 ] && tmux display "Can't maximize with only one pane" && return
# __window=$(tmux new-window -P "exec maximized+ 2> /dev/null | tmux setw remain-on-exit on && printf '\033]2;%s\033\\' [+]${__current_pane}")
# __window=${__window%.*}
#
# __guard=100
# while ( [ x"$(tmux list-panes -t ${__window} -F '#{session_name}:#{window_index} #{pane_dead}')" != x"${__window} "1 ] && [ x"${__guard}" != x0 ] ) ; do sleep 0.01 ; _guard=$((__guard - 1)) ; done
# if [ x"${__guard}" = 0 ] ; then
# exit 1
# fi
#
# __new_pane=$(tmux display -p '#{pane_id}')
# tmux setw remain-on-exit off \; swap-pane -s "${__current_pane}" -t "${__new_pane}"
# else
# ${__restore}
# fi
# }
#
# toggle_mouse() {
# old=$(tmux show-options | grep mouse | cut -d' ' -f2)
# new=""
#
# if [ "$old" = "on" ] ; then
# new="off"
# else
# new="on"
# fi
#
# tmux set mouse $new \;\
# display "mouse: $new"
# }
#
# battery() {
# battery_symbol=$1
# battery_symbol_count=$2
# if [ $battery_symbol_count = auto ]; then
# columns=$(tmux display -p '#{client_width}' || echo 80)
# if [ $columns -ge 80 ]; then
# battery_symbol_count=10
# else
# battery_symbol_count=5
# fi
# fi
# battery_full_fg=colour160
# battery_full_bg=colour16
# battery_empty_fg=colour254
# battery_empty_bg=colour16
#
# battery_symbol_heart_full=♥
# battery_symbol_heart_empty=♥
# battery_symbol_block_full=◼
# battery_symbol_block_empty=◻
# eval battery_symbol_full='$battery_symbol_'"$battery_symbol"'_full'
# eval battery_symbol_empty='$battery_symbol_'"$battery_symbol"'_empty'
#
# uname_s=$(uname -s)
# if [ $uname_s = Darwin ]; then
# batt=$(pmset -g batt)
# percentage=$(echo $batt |egrep -o [0-9]+%) || return
# charge="${percentage%%%} / 100"
# elif [ $uname_s = Linux ]; then
# batpath=/sys/class/power_supply/BAT0
# if [ ! -d $batpath ]; then
# batpath=/sys/class/power_supply/BAT1
# fi
# batfull=$batpath/energy_full
# batnow=$batpath/energy_now
# if [ ! -r $batfull -o ! -r $batnow ]; then
# return
# fi
# charge="$(cat $batnow) / $(cat $batfull)" || return
# fi
#
# full=$(printf %.0f $(echo "$charge * $battery_symbol_count" | bc -l))
# [ $full -gt 0 ] && \
# printf '#[fg=%s,bg=%s]' $battery_full_fg $battery_full_bg && \
# printf "%0.s$battery_symbol_full" $(seq 1 $full)
# empty=$(($battery_symbol_count - $full))
# [ $empty -gt 0 ] && \
# printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_empty_bg && \
# printf "%0.s$battery_symbol_empty" $(seq 1 $empty)
# }
#
# $@