-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy path.tmux.conf
More file actions
288 lines (223 loc) · 9.52 KB
/
.tmux.conf
File metadata and controls
288 lines (223 loc) · 9.52 KB
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
# vim: set ft=tmux:
# fixup colors so they are true color range
set-option -sa terminal-overrides ",xterm*:Tc"
unbind C-b
set -g prefix C-a
set-option -g prefix C-a
# set-option -g prefix C-b
bind-key -n C-b send-prefix
# bind C-b send-prefix
bind-key C-a last-window
bind-key C-c new-window
# allow repeat for next/prev with -r
bind-key -r C-n next-window
bind-key -r C-p previous-window
# not used, so commented
# bind-key C command-prompt -p "Name of new window: " "new-window -n '%%'"
# create new window on current path
bind-key C new-window -c "#{pane_current_path}"
# how to change default folder for a session
# attach-session -c "#{pane_current_path}"
set -s set-clipboard on
set -g terminal-overrides '*:smcup@:rmcup@'
# set -g status off
# For mouse people
# set -g mode-mouse on
# set -g mouse-select-window on
# set -g mouse-select-pane on
# set -g mouse on
# set -g mouse onbind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
# shortcuts to move window left and right
bind -r S-Left swap-window -t - \; select-window -t -
bind -r S-Right swap-window -t + \; select-window -t +
# detach client
bind-key d detach
bind-key C-d detach
# choose a client to detach
bind-key D choose-client
# choose window/session
bind-key '"' choose-window
bind-key 'S' choose-session
bind-key "'" run-shell 'tmux choose-tree -Nwf"##{==:##{session_name},#{session_name}}"'
# display visible indicator of each pane
bind-key w display-panes
# swap panes
bind-key -r J swap-pane -D
bind-key -r K swap-pane -U
# kill current pane/window
bind-key q confirm-before kill-pane
bind-key Q confirm-before kill-window
bind-key C-q confirm-before kill-pane
# Ctrl-Left/Right cycles thru windows (no prefix)
bind-key -n "C-Left" select-window -t :-
bind-key -n "C-Right" select-window -t :+
# Ctrl-Up/Down cyles thru panes (no prefix)
bind-key -n "C-Up" select-pane -t :.-
bind-key -n "C-Down" select-pane -t :.+
# title (default key in tmux is ',')
bind-key A command-prompt "rename-window %%"
# toogle status bar
bind-key t set -g status
# displays
bind-key * list-clients
# reload config
bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
set -g history-limit 10000
# Start numbering at 0
set -g base-index 0
# Relax!
set -sg escape-time 0
set -sg repeat-time 600
# neovim complained
set-option -g focus-events on
# listen for activity on all windows
set -g bell-action any
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
set -g display-time 400
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g renumber-windows on
setw -g automatic-rename on
set-option -g set-titles on
# Set nice title
set -g set-titles-string '#{client_user}@#H --> #{session_name} --> #{window_index}:#{window_name} --> #{pane_current_path}'
# y and p as in vim
# bind Escape copy-mode
# unbind p
# bind p paste-buffer
# bind -t vi-copy 'v' begin-selection
# bind -t vi-copy 'y' copy-selection
# bind -t vi-copy 'Space' halfpage-down
# bind -t vi-copy 'Bspace' halfpage-up
# Copy mode
setw -g mode-keys vi
bind [ copy-mode
bind Escape copy-mode
unbind p
bind p paste-buffer
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 y send-keys -X copy-selection-and-cancel
# easy-to-remember split pane commands
# bind-key | split-window -h
# bind-key - split-window -v
# bind-key _ split-window -v
# easy-to-remember split pane commands, keep current path
bind | split-window -h -c "#{pane_current_path}"
bind _ split-window -v -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# moving between panes with vim movement keys
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
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# resize panes with vim movement keys
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
# resize panes with vim movement keys - small step
bind -r < resize-pane -L 1
bind -r > resize-pane -R 1
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
# bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
set -g status-interval 15
# set default terminal - this is necessary for VIM begin and end to work
# set -g default-terminal screen-256color
set -g default-terminal tmux-256color
# THEME
set -g status-fg colour231
set -g status-bg colour234
set -g status-left-length 20
# set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]'
# pane border
set-option -g pane-border-style fg=colour238
set-option -g pane-active-border-style fg=colour114
# set-option -g pane-border-bg colour0
# set-option -g pane-border-bg default
# set-option -g pane-active-border-fg colour173
# set-option -g pane-active-border-fg colour215
# help at http://manpages.ubuntu.com/manpages/trusty/man1/tmux.1.html
# non selected window format
set -g window-status-format "#[bg=colour234]#[default] #[fg=colour244]#I #[default]#W#[fg=colour244]#{?window_zoomed_flag,#Z,} "
# Powerline
set -g status-left "#[fg=colour234,bg=colour114,bold]#S#[fg=colour114,bg=colour240,nobold]#[fg=colour240,bg=colour234,nobold] "
set -g window-status-current-format "#[fg=colour114,bg=colour234]#[fg=colour252,bg=colour114,nobold] #I:#[fg=colour231,bold]#W#[fg=colour231]#{?window_zoomed_flag,#Z,} #[fg=colour114,bg=colour234,nobold]"
set -g status-right '#[fg=colour240,bg=colour234]#[fg=colour234,bg=colour240] #(date +"%H:%M") #[fg=colour75,bg=colour240]#[fg=colour234,bg=colour75] #(hostname) '
set -g window-status-activity-style bold,fg=white,bg=colour236
# Simple fonts
# set -g status-left "#[fg=colour236,bg=colour114,bold]#S>"
# set -g window-status-current-format " #[fg=colour231,bg=colour173,nobold] #I.#[fg=colour231,bold]#W#[fg=colour231]#{?window_zoomed_flag,#Z,} "
# set -g status-right '#[fg=colour234,bg=colour240] #(date +"%H:%M") #[fg=colour234,bg=colour160] #(hostname) '
# Custom theme / settings for every PC
if '[ -f ~/.tmux.theme.conf ]' \
'source ~/.tmux.theme.conf'
# """"""""""""""
# " tmux fixes "
# """"""""""""""
# " Handle tmux $TERM quirks in vim
# if $TERM =~ '^screen-256color'
# map <Esc>OH <Home>
# map! <Esc>OH <Home>
# map <Esc>OF <End>
# map! <Esc>OF <End>
# endif
# Copycat nN-next,prev, y-copy, ctrl+ap paste
# 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/SHA-256 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
set -g @copycat_url_search 'c-b'
# List of plugins
# Install plugins with " c+a I "
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-open'
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
vim_pattern='(\S+/)?g?\.?(view|l?n?vim?x?|fzf)(diff)?(-wrapped)?'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +${vim_pattern}$'"
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
# restore session for vim and neovim
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
set -g @continuum-restore 'on' #set automatic sessions restore
set -g @continuum-save-interval '7' #set autosave interval to lower value
unbind -n C-u
bind C-u copy-mode \; send-keys -X halfpage-up
bind u copy-mode \; send-keys -X halfpage-up
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"
run '~/.tmux/plugins/tpm/tpm'