-
Notifications
You must be signed in to change notification settings - Fork 5
/
tmux.conf
275 lines (213 loc) · 9.16 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
# tmux.conf
# for tmux 2.1+ : mainly for tmux 2.3 and 2.4 (highly recommended)
#
# @seealso
# - http://manpages.ubuntu.com/manpages/precise/man1/tmux.1.html
# Set the TMUX_VERSION envvar (up to minor versions)
# https://stackoverflow.com/a/40902312/1046584
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
# 1. Key Bindings {{{
# ===================
# Key combination prefix is <C-a>, not <C-b>
set-option -g prefix C-a
unbind-key C-b
# enable vi-mode
setw -g mode-keys vi
# Enable mouse behavior.
# if TMUX 2.1+
set -g mouse on
# else
#setw -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
# synchronize-panes
bind-key y set-window-option synchronize-panes # usage: <leader>y
# Enable-Disable input on specific panes
# bind-key D select-pane -d
# bind-key E select-pane -e
# some useful <C-a> combinations
bind-key : command-prompt
bind-key r source-file ~/.tmux.conf \; display "Reloaded from ~/.tmux.conf"
bind-key L clear-history
#bind-key space next-window
bind-key bspace previous-window
#bind-key enter next-layout
bind-key C-o rotate-window
#bind-key + select-layout main-horizontal
#bind-key = select-layout main-vertical
#set-window-option -g other-pane-height 25
#set-window-option -g other-pane-width 80
# vertical/horizontal split
bind-key v split-window -h -c "#{pane_current_path}"
bind-key s split-window -v -c "#{pane_current_path}"
#bind-key | split-window -h -c "#{pane_current_path}"
#bind-key _ split-window -v -c "#{pane_current_path}"
bind-key > resize-pane -R 10
bind-key < resize-pane -L 10
bind-key + resize-pane -D 5
bind-key - resize-pane -U 5
# pane/windows navigation
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key q display-panes
#bind-key C-a last-window
bind-key c new-window
#bind-key t next-window
#bind-key T previous-window
bind-key 0 select-window -t :0
bind-key 1 select-window -t :1
bind-key 2 select-window -t :2
bind-key 3 select-window -t :3
bind-key 4 select-window -t :4
bind-key 5 select-window -t :5
bind-key 6 select-window -t :6
bind-key 7 select-window -t :7
bind-key 8 select-window -t :8
bind-key 9 select-window -t :9
#bind-key , previous-window # select left
#bind-key . next-window # select right
bind-key Left previous-window # move left
bind-key Right next-window # move left
# move windows
bind-key S-Left swap-window -t :- # move left
bind-key S-Right swap-window -t :+ # move right
# bind-key / command-prompt "move-window -t '%%'"
# change name of the current window (shift-a)
# bind-key A command-prompt -I "#W" "rename-window '%%'"
# change number of the current window
# bind-key % command-prompt -I "#I" "move-window -t '%%'"
# synchronize mode (toggle)
# bind-key e set-window-option synchronize-panes
# In pane synchronize mode, make all pane borders yellow and the active one orange.
# NOTE: make sure that the following color configuration is compatible with
# 'pane-border-fg', 'pane-active-border-fg', etc.
# bind e if -F '#{pane_synchronized}' \
# 'setw synchronize-panes off; \
# setw pane-border-fg colour240; \
# setw pane-active-border-style fg=green,bg=default; \
# ' \
# 'setw synchronize-panes on; \
# setw pane-border-fg colour226; \
# setw pane-active-border-style fg=colour202,bg=default; \
# ' \
# Clunkily connect tmux buffers with the pasteboard.
# bind-key Escape copy-mode
# bind-key Enter copy-mode
# bind-key ] paste-buffer
# vi-mode v: Begin visual-selection in copy mode.
# vi-mode y: Yank the current selection in copy mode.
if-shell -b '[ "$(echo "$TMUX_VERSION <= 2.3" | bc)" = 1 ]' \
'bind-key -t vi-copy "v" begin-selection; \
bind-key -t vi-copy "y" copy-pipe "pbcopy"; \
'
# see https://github.com/tmux/tmux/issues/754
# see https://github.com/tmux/tmux/issues/592
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
'bind -T copy-mode-vi "v" send-keys -X begin-selection; \
bind -T copy-mode-vi "y" send-keys -X copy-pipe-and-cancel "pbcopy"; \
'
bind-key 'p' run-shell "pbpaste | tmux load-buffer - && tmux paste-buffer"
# no delay when switching modes (copy mode, etc.)
set -sg escape-time 0
set-window-option -g display-panes-time 1500
# }}}
# 2. Appereance and General Preferences {{{
# =========================================
# see @tmux-pugins/vim-tmux-focus-events
set -g focus-events on
# Color and Themes
set-option -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc" # True-color (24bit)
# let pane/window numbers be 1-indexed
set-option -g base-index 1
set-option -g pane-base-index 1
# Status Bar
# Update status every 1 seconds
set-option -g status-interval 1
# No automatic renaming of windows (from commands on execution)
set-window-option -g automatic-rename off
# Set title, which is also showed at iTerm tab
# For special character sequences such as #S, refer to manual
set-option -g set-titles on
set-option -g set-titles-string '#S #I:#W (#h)' # session name, window index, window title, hostname
# Status Bar: auto-generated by tmuxline.vim
set -g status-justify "left"
set -g status "on"
set -g status-left-style "none"
set -g message-command-style "fg=colour231,bg=colour31"
set -g status-right-style "none"
#set -g status-utf8 "on"
set -g status-style "bg=colour234,none"
set -g message-style "fg=colour231,bg=colour31"
set -g pane-border-style "fg=colour240"
set -g status-right-length "100"
set -g status-left-length "100"
TMUX_STATUS_BG="colour$PROMPT_HOST_COLOR"
setw -g window-status-activity-attr "none"
setw -g window-status-activity-style "fg=colour250,bg=colour234,underscore"
setw -g window-status-separator ""
setw -g window-status-style "fg=colour250,bg=colour234,none"
set -g status-left "#[fg=colour16,bg=$TMUX_STATUS_BG,bold] #S #[fg=colour234,bg=$TMUX_STATUS_BG,nobold,nounderscore,noitalics]#[fg=$TMUX_STATUS_BG,bg=colour234] #h "
set -g status-right "#{prefix_highlight}#[fg=colour236,bg=colour234,nobold,nounderscore,noitalics]#[fg=colour247,bg=colour236] %Y-%m-%d %H:%M #[fg=colour252,bg=colour236,nobold,nounderscore,noitalics]"
setw -g window-status-format "#[fg=colour31,bg=colour234] #I#F#[fg=colour250,bg=colour234] #W "
setw -g window-status-current-format "#[fg=colour234,bg=colour31,nobold,nounderscore,noitalics]#[fg=colour87,bg=colour31] #I#F#[fg=colour231,bg=colour31,bold] #W #{?pane_synchronized,#[fg=colour190](SYNC),} #[fg=colour31,bg=colour234,nobold,nounderscore,noitalics]"
#{prefix_highlight}
# pane border colors
set-option -g pane-border-fg colour240 # inactive pane border: gray
set-option -g pane-border-bg default
set-option -g pane-active-border-fg green # active pane border: green
set-option -g pane-active-border-bg default
# Pane number and title shown on the border
#set-option -g pane-border-status 'top'
#set-option -g pane-border-format '(#{pane_index}) #{?pane_active,#[fg=colour156],}#T#F'
# (DISABLED) Auto hide pane-border-status line when only one pane is displayed (see tmux/tmux#566)
#set-hook -g 'after-new-window' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
#set-hook -g 'after-kill-pane' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
#set-hook -g 'pane-exited' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
#set-hook -g 'after-split-window' 'run-shell -b "if [ \#{window_panes} -gt 1 ]; then tmux set pane-border-status top; fi"'
# window notifications
set-window-option -g monitor-activity on
set-option -g visual-activity off # no 'Activity in window <n>'
# Allow the arrow key to be used immediately after changing windows
set-option -g repeat-time 0
# Environment should be read from the parent environment
set -g update-environment -r
# More history and scrollback
set-option -g history-limit 100000
# }}}
# 3. vim-tmux-navigator {{{
# =========================
# Smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(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"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "send-keys C-l"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# }}}
# 3. Tmux Plugins {{{
# ===================
# List of plugins
# @see https://github.com/tmux-plugins/tpm
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'nhdaly/tmux-scroll-copy-mode'
#set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'laktak/extrakto'
# tmux-prefix-highlight
set -g @prefix_highlight_output_prefix ' '
set -g @prefix_highlight_output_suffix ' '
# tmux-copycat
# use vim-like navigation (n, N)
set -g @copycat_next 'N'
set -g @copycat_prev 'n'
# extrakto
set -g @extrakto_split_size "12"
# Enable plugins
run-shell '~/.tmux/plugins/tpm/tpm'
# }}}