-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
.tmux.conf
284 lines (215 loc) · 9.71 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
#################
# TMUX CONFIG #
#################
# set prefix
unbind-key C-b
set-option -g prefix C-b
bind-key C-b send-prefix
#############
# OPTIONS #
#############
# use vi keys
set-option -gw mode-keys vi
# set bigger history limit
set-option -g history-limit 1000000
# so you don't end up with window numbers like: 0 1 4 5 6
set-option -g renumber-windows on
# mouse support
set-option -g mouse on
# set title
set-option -g set-titles on
set-option -g set-titles-string "tmux [#S]"
# 256 color support
set-option -g default-terminal 'tmux-256color'
set-option -g default-terminal "${TERM}"
set-option -ga terminal-overrides ',xterm-termite:Tc,xterm-kitty:Tc,alacritty:Tc,xterm-256color:Tc'
set-option -ga terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set-option -ga terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
# style of function key sequences
set-window-option -g xterm-keys on
# start window numbers from 1
set-option -g base-index 1
# set escape time so vim is responsive inside tmux
set-option -g escape-time 1
# show statusbar
set-option -g status on
# status bar redraw interval
set-option -g status-interval 5
# status position
set-option -g status-position bottom
# wrap search
set-option -g wrap-search on
# repeat time
set-option -g repeat-time 700
##############
# BINDINGS #
##############
# reload tmux config
bind-key r source-file ~/.tmux.conf \; display-message "Reloaded ~/.tmux.conf"
# source .tmux file
bind-key T confirm-before -p "Source .tmux file? (y/N)" "source-file .tmux"
# kill session / window / panel
bind-key S confirm-before -p "Kill session '#S'? (y/N)" kill-session
bind-key W confirm-before -p "Kill window '#W'? (y/N)" kill-window
bind-key P confirm-before -p "Kill pane '#T'? (y/N)" kill-pane
# rename session / window / panel
bind-key M-S command-prompt -p "Rename session:" -I '#S' 'rename-session %1'
bind-key M-W command-prompt -p "Rename window:" -I '#W' 'rename-window %1'
bind-key M-P command-prompt -p "Rename pane:" -I '#T' 'rename-pane %1'
bind-key $ command-prompt -p "Rename session:" -I '#S' 'rename-session %1'
bind-key , command-prompt -p "Rename window:" -I '#W' 'rename-window %1'
# create new panes and windows
bind-key C-v split-window -h -c "#{pane_current_path}"
bind-key v split-window -h
bind-key C-x split-window -v -c "#{pane_current_path}"
bind-key x split-window -v
bind-key C-c new-window -a -c "#{pane_current_path}"
bind-key c new-window
# create small horizontal pane
bind-key C-u split-window -v -l 3 -c "#{pane_current_path}"
# smart pane switching with awareness of vim splits
# makes ctrl-j and ctrl-k navigate fzf search results when fzf active in pane
# providing the same behavior as ctrl-j and ctrl-k when navigating ctrl-p
# results inside vim.
IS_VIM="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
IS_FZF="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
# switch panes
bind-key -n C-h if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-l" "select-pane -R"
# switch panes (copy-mode)
bind-key -T copy-mode-vi C-h if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-h" "select-pane -L"
bind-key -T copy-mode-vi C-j if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-j" "select-pane -D"
bind-key -T copy-mode-vi C-k if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-k" "select-pane -U"
bind-key -T copy-mode-vi C-l if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-l" "select-pane -R"
bind-key -T copy-mode C-h if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-h" "select-pane -L"
bind-key -T copy-mode C-j if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-j" "select-pane -D"
bind-key -T copy-mode C-k if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-k" "select-pane -U"
bind-key -T copy-mode C-l if-shell "${IS_VIM} || ${IS_FZF}" "send-keys C-l" "select-pane -R"
# fallback
bind-key C-h select-pane -L
bind-key C-j select-pane -D
bind-key C-k select-pane -U
bind-key C-l select-pane -R
# resize panes
bind-key -r h resize-pane -L 5
bind-key -r j resize-pane -D 5
bind-key -r k resize-pane -U 5
bind-key -r l resize-pane -R 5
# spread panes out evenly
bind-key C-e select-layout -E
# select pane
bind-key C-m select-pane -m
bind-key m select-pane -M
# change split direction
bind-key V move-pane -h -t '.-'
bind-key X move-pane -v -t '.-'
# join panes
bind-key M-v join-pane -h
bind-key M-x join-pane -v
# rotate panes
bind-key C-r rotate-window
# swap panes
bind-key -r H swap-pane -U
bind-key -r L swap-pane -D
# swap windows
bind-key -r M-h swap-window -s -1 \; previous-window
bind-key -r M-l swap-window -s +1 \; next-window
bind-key -r < swap-window -s -1 \; previous-window
bind-key -r > swap-window -s +1 \; next-window
# swap marked
bind-key M-p swap-pane \; select-pane -M
bind-key M-w swap-window \; select-pane -M
# switch windows
bind-key -n M-h previous-window
bind-key -n M-l next-window
# switch session
bind-key C-n switch-client -n
bind-key C-p switch-client -p
# move window
bind-key M-m command-prompt -p 'Move window to here:' -I '#S:#I' 'move-window -s %1'
bind-key M command-prompt -p 'Move this window to:' -I '#S:#I' 'move-window -t %1'
# link / unlink window
bind-key M-b command-prompt -p 'Link window:' -I '#S:#I' 'if-shell -F "%1" "link-window -s %1" "unlink-window"'
bind-key B unlink-window
# save buffer to file
bind-key M-s command-prompt -p 'Save history to filename:' -I '~/.tmux_history' 'capture-pane -S - -E - ; save-buffer %1 ; delete-buffer'
# display panes
bind-key C-d display-panes
# toggle status bar
bind-key C-s set-option status
# toggle pane border status
bind-key C-t set-option -g pane-border-status
# toggle synchronize
bind-key ^ set-window-option synchronize-panes
###############
# COPY MODE #
###############
# set clipboard
set-option -g set-clipboard external
# copy and paste
bind-key C-y copy-mode
bind-key y copy-mode
bind-key p paste-buffer
# copy mode bindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi Space send-keys -X clear-selection
bind-key -T copy-mode-vi d send-keys -X halfpage-down
bind-key -T copy-mode-vi u send-keys -X halfpage-up
bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear 'xclip -in -selection clipboard'
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear 'xclip -in -selection primary'
bind-key -T copy-mode-vi q send-keys -X cancel
bind-key -T copy-mode-vi ä send-keys -X back-to-indentation
bind-key -T copy-mode-vi / command-prompt -p '/' 'send-keys -X search-backward %1'
bind-key -T copy-mode-vi ? command-prompt -p '?' 'send-keys -X search-forward %1'
bind-key -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send-keys -X clear-selection' 'send-keys -X cancel'
# scroll speed
bind-key -T copy-mode-vi WheelUpPane send-keys -N 1 -X scroll-up
bind-key -T copy-mode-vi WheelDownPane send-keys -N 1 -X scroll-down
bind-key -T copy-mode WheelUpPane send-keys -N 1 -X scroll-up
bind-key -T copy-mode WheelDownPane send-keys -N 1 -X scroll-down
####################
# MOUSE BINDINGS #
####################
bind-key -n DoubleClick1StatusLeft switch-client -n
###################
# MISC BINDINGS #
###################
# open git log (or dotfiles log if not available)
bind-key C-g split-window -h -f -d -c "#{pane_current_path}" "git lg || ([[ $? -ne 141 ]] && dotfiles lg)"
bind-key g respawn-pane -t "{right}" -k "git lg || ([[ $? -ne 141 ]] && dotfiles lg)"
bind-key C-o split-window -h -f -d -c "#{pane_current_path}" "git lgo || ([[ $? -ne 141 ]] && dotfiles lgo)"
bind-key o respawn-pane -t "{right}" -k "git lgo || ([[ $? -ne 141 ]] && dotfiles lgo)"
bind-key C-q kill-pane -t "{right}"
###############
# STATUSBAR #
###############
# Use minimal statusbar if in TTY, otherwise use powerline statusbar
if-shell -F "#{==:${TERM},linux}" \
"source-file ~/.config/tmux/tty-status.conf" \
"source-file ~/.config/tmux/minimal-status.conf"
#############
# PLUGINS #
#############
set-option -g @plugin 'tmux-plugins/tpm'
set-option -g @plugin 'tmux-plugins/tmux-sensible'
#set-option -g @plugin 'tmux-plugins/tmux-resurrect'
#set-option -g @plugin 'tmux-plugins/tmux-continuum'
#set-option -g @plugin 'tmux-plugins/tmux-copycat'
#set-option -g @plugin 'tmux-plugins/tmux-yank'
set-option -g @plugin 'NHDaly/tmux-better-mouse-mode'
set-option -g @plugin 'tmux-plugins/vim-tmux-focus-events'
# plugin settings
#set-option -g @continuum-boot 'on'
#set-option -g @continuum-systemd-start-cmd 'new-session -d -s main'
#set-option -g @resurrect-strategy-vim 'session'
set-option -g @scroll-down-exit-copy-mode 'on'
set-option -g @scroll-without-changing-pane 'on'
set-option -g @scroll-in-moused-over-pane 'on'
set-option -g @scroll-speed-num-lines-per-scroll '1'
set-option -g @emulate-scroll-for-no-mouse-alternate-buffer 'on'
# initialize tpm (keep this line at the very bottom of .tmux.conf)
run-shell '~/.tmux/plugins/tpm/tpm'