-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_tmux.conf
208 lines (170 loc) · 7.13 KB
/
dot_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
# Nested TMUX sessions (from
# https://medium.freecodecamp.org/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795)
bind -T root F11 \
set prefix None \;\
set key-table off \;\
set status-right "#[fg=colour0,bg=colour1] DISABLED #[fg=colour3,bg=colour0] #{session_name}#[fg=colour1] | #[fg=colour2]%d %b %l:%M %p "
refresh-client -S \;\
bind -T off F11 \
set -u prefix \;\
set -u key-table \;\
set -u status-right \;\
refresh-client -S
# improve colors
set -g default-terminal 'tmux-256color'
set -as terminal-overrides ',xterm*:Tc:smso=\E[3m'
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
set-option -g allow-rename off
set-window-option -g automatic-rename off
# Status bar
set -g set-titles 'off'
set -g status-position 'top'
set -g status-style 'bg=#fbfafc'
set -g status-left ""
set -g status-right-length 200
set -g status-right "#[fg=white,bg=#7653c1] vsim #[fg=white,bg=#404a54] #(ps hux -u $(whoami) | grep 'vish' | grep -v -E 'grep|view' | wc -l) #[fg=colour3,bg=default] #[fg=colour0,bg=colour3] load #[fg=white,bg=#404a54] #(cat /proc/loadavg | awk '{ print $3; }' | xargs printf '%2.2f') #[fg=colour3,bg=default] #[fg=colour0,bg=#73b00a] mem #[fg=white,bg=#404a54] #(ps haux | awk -v user=$(whoami) '$1 ~ user { sum += $4 } END { print sum; }' | xargs printf '%2.2f')% #[fg=colour3,bg=default] #[fg=white,bg=#cf4f5f] time #[fg=white,bg=#404a54] %d %b %l:%M %p #[fg=colour3,bg=default] #[fg=colour15,bg=colour8] #{session_name} #[fg=colour0,bg=default]"
# Tabs
setw -g window-status-format " #I #W "
setw -g window-status-style "fg=#404a54,bg=#e3ebf1"
setw -g window-status-current-format " #I #W "
setw -g window-status-current-style "bg=#404a54,fg=#ffffff"
set -g status-justify "left"
setw -g window-status-bell-style "fg=#ffffff,bg=#d44950"
setw -g mode-style "bg=#fbe9ad"
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
bind c command-prompt -p "Name:" "new-window -c \"#{pane_current_path}\" -n %%"
# Enable delete in command sequencer
bind h send-keys 'c-h'
# Open man pages in split
bind @ command-prompt -p "Man:" "split-window -v 'exec man %%'"
# act like vim
bind Escape copy-mode
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'V' send -X select-line
bind-key -T copy-mode-vi 'r' send -X rectangle-toggle
unbind-key -T copy-mode-vi MouseDragEnd1Pane
unbind -T copy-mode-vi MouseDragEnd1Pane
# Copy and Paste selection on middle mouse
bind-key -T copy-mode-vi MouseDown2Pane send-keys -X copy-pipe-and-cancel "tmux paste-buffer"
# 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 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi ] send-keys -X next-prompt
bind-key -T copy-mode-vi [ send-keys -X previous-prompt
unbind C-b
set -g prefix C-Space
bind Space send-prefix
set -g escape-time 20
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
bind-key r source ~/.tmux.conf
# Fix hightlighting in less
set -ga terminal-overrides ',*:sitm@,ritm@'
# increase scrollback lines
set -g history-limit 100000
setw -g mouse on
set -g focus-events on
# Allow for visual bell when a command completes
set-window-option -g visual-bell on
set-window-option -g bell-action other
# Allow OSC52 from applications
set -s set-clipboard on
# Local config
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'
# Config
set -g @scroll-without-changing-pane "on"
set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"
run-shell ~/.tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux
run-shell ~/.tmux/plugins/tmux-yank/yank.tmux
run-shell ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.tmux
set -g @thumbs-osc52 0
# Swap behaviour
set -g @thumbs-command 'tmux set-buffer -w -- {} && tmux paste-buffer && tmux display-message \"Copied {}\"'
set -g @thumbs-upcase-command 'tmux set-buffer -w -- {} && tmux display-message \"Copied {}\"'
set -g @thumbs-hint-fg-color red
set -g @thumbs-reverse enabled
bind-key -n 'C-q' popup -w50% -h 90% -x 90% -E -d '#{pane_current_path}' chezmoi cd
bind-key -n 'C-z' if -F '#{window_zoomed_flag}' "resize-pane -Z" "send-keys C-z"
bind-key -T copy-mode-vi 'C-s' {
copy-mode
send -X clear-selection
send -X start-of-line
send -X start-of-line
send -X cursor-up
send -X cursor-up
send -X start-of-line
send -X start-of-line
if -F "#{m:*->\u00A0*,#{copy_cursor_line}}" {
send -X search-forward-text "->\u00A0"
send -X stop-selection
send -X -N 2 cursor-right
send -X begin-selection
send -X end-of-line
send -X end-of-line
if "#{m:*->\u00A0?*,#{copy_cursor_line}}" {
send -X cursor-left
}
} {
send -X end-of-line
send -X end-of-line
send -X begin-selection
send -X search-backward-text "->\u00A0"
send -X end-of-line
send -X end-of-line
send -X cursor-right
send -X stop-selection
}
}
bind-key -T copy-mode-vi 's' send -X copy-pipe-and-cancel "cat > /tmp/error.txt && tmux new-window -n 'quickfix' -c \"#{pane_current_path}\" 'nvim -q /tmp/error.txt && rm -f /tmp/error.txt'"
bind-key 'o' {
copy-mode
send -X clear-selection
send -X start-of-line
send -X start-of-line
send -X cursor-up
send -X cursor-up
send -X start-of-line
send -X start-of-line
if -F "#{m:*->\u00A0*,#{copy_cursor_line}}" {
send -X search-forward-text "->\u00A0"
send -X stop-selection
send -X -N 2 cursor-right
send -X begin-selection
send -X end-of-line
send -X end-of-line
if "#{m:*->\u00A0?*,#{copy_cursor_line}}" {
send -X cursor-left
}
} {
send -X end-of-line
send -X end-of-line
send -X begin-selection
send -X search-backward-text "->\u00A0"
send -X end-of-line
send -X end-of-line
send -X cursor-right
send -X stop-selection
}
send -X copy-pipe-and-cancel "grep -oE '([^\s]+)\/([^/]+)' | fzf-tmux -d20 --multi --bind alt-a:select-all,alt-d:deselect-all | paste -sd \" \" - | xargs -I {} tmux send-keys -t #{pane_id} \"{}\""
}
# unbind after loading plugins
unbind -T copy-mode-vi MouseDragEnd1Pane