-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
executable file
·351 lines (316 loc) · 16.3 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
# Command Cheatsheet:
################################################################################
# PREFIX x Confirm before kill pane
# PREFIX q Display panes
# PREFIX <space> Next layout (split panes horizontal if panes were vertically splitted and inversely)
# PREFIX " Split Window vertically
# PREFIX % Split Window horizontally
# PREFIX c New Window
# PREFIX & Confirm before kill window
# PREFIX d Detach client and quit tmux (but leave tmux session running)
# PREFIX : Command prompt
# PREFIX C-o Rotate Panes location in current window
# PREFIX o Switch active pane to next pane
# PREFIX # List of paste buffers
# PREFIX $ Rename the current session
# PREFIX [0..9] Select window 0 to 9
# PREFIX C[arrow] Resize pane
# PREFIX k Clear Terminal and Terminal history
# PREFIX :source-file ~/.tmux.conf Reload tmux configuration file
# PREFIX z Zoom (temporaly) current pane to 100% window size (tmux 1.8+)
# PREFIX :break-pane Break current pane in new window
# PREFIX :join-pane -t [window] Join current pane in window [window]
# PREFIX # List paste buffers
# PREFIX - Delete most recently copied buffer
# PREFIX = Choose which buffer to paste interactively from a list
# PREFIX [ Enter copy mode. // Remaped
# PREFIX ] Paste the most recently copied buffer . // Remaped
#
# Shell command Cheatsheet:
################################################################################
# <tmux> = tmux | PREFIX :
# <tmux> list-keys -t vi-copy Prints all current vi-copy bindings
# <tmux> show-options -g Print window options
# <tmux> show-options -w Print server options
# <tmux> show-options -s Print session options
# Sources:
# - http://arcoleo.org/dsawiki/Wiki.jsp?page=Tmux%20Reference
# - http://blog.joncairns.com/2013/06/copying-between-tmux-buffers-and-the-system-clipboard/
# - https://leanpub.com/the-tao-of-tmux/read
################################################################################
# Boostrap
################################################################################
#Set tmux version
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | awk '{ print $2 }')"
# PREFIX remapping
# Forbidden prefixes keys:
# - backtic - conflicts with vim's marks
# - Ctrl-a - conflicts with nothing but too long
# - capslock - no tmux support
#
unbind C-b
#set-option -g prefix C-a
#bind C-a send-prefix
set-option -g prefix `
bind ` send-prefix
################################################################################
# Theme
################################################################################
source-file "$HOME/.tmux/themes/pimux-bluish.tmux"
################################################################################
# Server options
################################################################################
# Set correct term
set-option -sg default-terminal screen-256color
# Faster command sequence (when in tmux+vim)
set-option -sg escape-time 0
# Max buffers
set-option -sg buffer-limit 1000
# Command history
set-option -sg history-file ~/.tmux_history
# Maximung number of lines held in Window history
set-option -sg history-limit 199999
################################################################################
# Session options
################################################################################
# No activity notification
set-option -g activity-action none
set-option -g visual-activity on
set-option -g visual-bell off
set-option -g visual-silence on
# Window numbering start at 1
set-option -g base-index 1
# Automatically set window title
set-option -g set-titles on
# Aggressive resize instead of having all windows in a session contraint to the
# size of the smallest client connected to the session even if both clients
# are looking at a different window.
set-option -g aggressive-resize on
# Duration status message/other on screen indicator
set-option -g display-time 2000
# Renumber windows
set-option -g renumber-windows off
# list of environment variables to be copied into the session environment when:
#- a new session is created or an existing session is attached.
set-option -g update-environment "GPG_AGENT_INFO GPG_AGENT_INFO SSH_AGENT_PID SSH_AUTH_SOCK SSH_CONNECTION WINDOWID XAUTHORITY XDG_SESSION_COOKIE XDG_SESSION_PATH"
# Considers key presses within less than the duration below to be pasted rather
# typed. Do not process them as keys
set-option -g assume-paste-time 100
# Define which apps can write to tmux's internal system clipboard buffer
# - on - tmux accepts the escape sequence to create a buffer and attempt to set the terminal clipboard.
# - external - tmux attempts to set the terminal clipboard but ignore attempts by applications to set tmux buffers.
# - off - tmux neither accept the clipboard escape sequence nor attempt to set the clipboard.
set-option set-clipboard on
################################################################################
# Status Line
################################################################################
# Updates status every 1s
set-option -g status-interval 1
# Force theme to place status bar at the botoom
set-option -g status-position bottom
################################################################################
# Panes
################################################################################
# Force theme to show active pane in blue
set -g pane-active-border-style fg=blue
################################################################################
# Window options
################################################################################
# Automatically rename window
set-window-option -g automatic-rename on
# Hightlight current windows
# - currently set by theme
#set-window-option -g window-status-current-fg $HIGHLIGHT
#set-window-option -g window-status-current-bg $BACKGROUND
setw -g window-status-current-style bold
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
# Dim non current windows
# - currently set by theme
#setw -g window-status-fg $FOREGROUND
#setw -g window-status-bg $BACKGROUND
setw -g window-status-style none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
# Highlight window with activity
set-window-option -g monitor-activity on
################################################################################
# Mouse
################################################################################
# Enable mouse control
# - Automatically copy selected content on system clipboard
if-shell 'expr $TMUX_VERSION \>= 2.1' \
"set -g mouse on"
if-shell 'expr $TMUX_VERSION \< 2.1' \
"set -g mouse-select-window on; set -g mouse-select-pane on; set -g mouse-resize-pane on"
################################################################################
# Key modes
################################################################################
# Enable vi style key bindings
set-window-option -g mode-keys vi
################################################################################
# Key bindings
# defaults: https://github.com/tmux/tmux/blob/master/key-bindings.c#L190
# current: command tmux list-keys
################################################################################
# Reloads tmux's user conf
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded!"
# Choose session
bind-key s choose-session
# Enable vi style copy/paste
# - How to copy/paste ?
# 1. Enter copy mode : PREFIX `
# 2. Begin visual selection : v
# 3. Ends visual selection and yank text to buffer : y
# 4. Paste text from buffer: PREFIX p
unbind-key [ ; bind-key ` copy-mode # prefix + Escape starts copy mode
unbind-key ] ; unbind-key p; bind-key p paste-buffer # pastes the latest buffer
if-shell 'expr $TMUX_VERSION \>= 2.4' \
"bind-key -T copy-mode-vi v send-keys -X begin-selection " # begins content selection
if-shell 'expr $TMUX_VERSION \>= 2.4' \
"bind-key -T copy-mode-vi y send-keys -X copy-selection " # copies selected content to 1 of tmux's paste buffers
if-shell 'expr $TMUX_VERSION \>= 2.4' \
"bind-key -T copy-mode-vi V send-keys -X rectangle-toggle " # switch between line and columnwise selection
if-shell 'expr $TMUX_VERSION \< 2.4' \
"bind-key -t vi-copy v begin-selection " # begins content selection
if-shell 'expr $TMUX_VERSION \< 2.4' \
"bind-key -t vi-copy y copy-selection" # copies selected content to 1 of tmux's paste buffers
if-shell 'expr $TMUX_VERSION \< 2.4' \
"bind-key -t vi-copy v rectangle-toggle'" # switch between line and columnwise selection
# Re-copy tmux buffer to macOS system clipboard
bind y run-shell "tmux show-buffer | pbcopy" \; display-message "Copied tmux buffer to system clipboard"
# Clear shell terminal and tmux history at once like Terminal's Cmd+k
# Inspired from: http://stackoverflow.com/questions/10543684/how-can-i-clear-scrollback-buffer-in-tmux
# Inspired from: https://superuser.com/a/686784
bind C-y send-keys ^c clear Enter \; run-shell "sleep .3s" \; clear-history
# Resizing panes with Ctrl-[hjkl]
# - Keep it in sync with vim window resizing keybindings
bind-key C-l resize-pane -R 5
bind-key C-h resize-pane -L 5
bind-key C-j resize-pane -D 3
bind-key C-k resize-pane -U 3
bind-key C-w select-layout "even-horizontal"
# Move around panes with Ctrl [hjkl] (similar to vim-tmux-navigator)
# (Navigating vim/tmux splits)
# Smart pane switching with awareness of Vim splits. Now, I can use Ctrl+hjkl
# in both Vim and Tmux (without using the prefix). Based on
# http://www.codeography.com/2013/06/19/navigating-vim-and-tmux-splits.
# Note: I do not use https://github.com/christoomey/vim-tmux-navigator because
# it does not work when vim is run over ssh.
# Note: The "... || true" part is there to prevent annoying messages when there
# is no pane to switch into.
# Note: In the grep regular expression, '^vim$' matches Vim run from terminal,
# and '- VIM$' matches Vim run from Midnight Commander.
# src: https://github.com/s3rvac/dotfiles/blob/master/tmux/.tmux.conf#L69
bind -n C-h run "(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-h) || (tmux select-pane -L || true)"
bind -n C-j run "(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-j) || (tmux select-pane -D || true)"
bind -n C-k run "(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-k) || (tmux select-pane -U || true)"
bind -n C-l run "(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-l) || (tmux select-pane -R || true)"
# Since tmux 2.6, the following two bindings have to be also set from the copy
# mode. Otherwise, they will not work in the copy mode.
if-shell '[ $(echo "$(tmux -V | cut -d" " -f2) >= 2.6" | bc) -eq 1 ]' \
"bind -T copy-mode-vi -n C-h run \"(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-h) || (tmux select-pane -L || true)\"" ""
if-shell '[ $(echo "$(tmux -V | cut -d" " -f2) >= 2.6" | bc) -eq 1 ]' \
"bind -T copy-mode-vi -n C-j run \"(tmux display-message -p '#{pane_title}' | grep -q '\\(- VIM$\\|^vim$\\)' && tmux send-keys C-j) || (tmux select-pane -D || true)\"" ""
# Move around panes with PREFIX hjkl
# - Vim style
# - Keep it in sync with vim's ctrl-w [hjkl] (to move around windows)
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# - Alternative to move around panes: Alt-arrow without PREFIX
bind-key -n M-Left select-pane -L
bind-key -n M-Right select-pane -R
bind-key -n M-Up select-pane -U
bind-key -n M-Down select-pane -D
# Pane splitting
# - Keep it in sync with vim's default window vertical/horizontal splits (<leader> C-w s / <leader> C-w v)
# - vim's definition of a horizontal/vertical split is reversed from tmux's
bind-key C-s split-window -v -c '#{pane_current_path}'
bind-key C-v split-window -h -c '#{pane_current_path}'
# Deprecated pane split mapping. Vim's default are perfect.
# bind-key | split-window -h -c "#{pane_current_path}"
# bind-key - split-window -v -c "#{pane_current_path}"
# Go to last accessed window
# - Keep it in sync with vim's ???? binding
# - FIXME: Define proper key-binding for this. Current binding is not a good one
bind-key C-p last-window
# Sync input on 1 or all panes on the same window
# - FIXME: Define proper key-binding for this. PREFIX y is not a good one
bind-key M-y set-window-option synchronize-panes \; display-message "synchronize-panes: #{?synchronize-panes,on,off}"
################################################################################
# Plugins
################################################################################
# Provides:
# - plugin update/delete/update
set -g @plugin 'tmux-plugins/tpm'
# Provides restore/save capability for:
# - all sessions, windows, panes and their order
# - current working directory for each pane
# - exact pane layouts within windows (even when zoomed)
# - active and alternative session
# - active and alternative window for each session
# - windows with focus
# - active pane for each window
# - "grouped sessions" (useful feature when using tmux with multiple monitors)
# - programs running within a pane! More details in the restoring programs doc.
# NOTE: if-shell 'expr $TMUX_VERSION \>= 1.9' \ " set -g @plugin 'tmux-plugins/tmux-resurrect' " does not allow tpm to load the plugin
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Provides:
# - continuous saving of tmux environment
# - automatic tmux start when computer/server is turned on
# - automatic restore when tmux is started
# NOTE: if-shell 'expr $TMUX_VERSION \>= 2.4' \ " set -g @plugin 'tmux-plugins/tmux-continuim' " does not allow tpm to load the plugin
set -g @plugin 'tmux-plugins/tmux-continuum'
# Provides:
# (in copy-mode) o - "open" a highlighted selection with the system default program. open for OS X or xdg-open for Linux.
# (in copy-mode) Ctrl-o - open a highlighted selection with the $EDITOR
# (in copy-mode) Shift-s - search the highlighted selection directly inside a search engine (defaults to google)
set -g @plugin 'tmux-plugins/tmux-open'
# Provides:
# - Regex search
# - search result highlighting
# - predefined searches (simple file, git status file, url, number, ip)
# Notable keybinding
# - prefix + / - regex search (strings work too)
# - 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
# Moving through search results
# n - jumps to the next match
# N - jumps to the previous match
# To copy a highlighted match:
# Enter - when using Tmux's vi mode
# NOTE: if-shell 'expr $TMUX_VERSION \>= 2.4' \ " set -g @plugin 'tmux-plugins/tmux-copycat' " does not allow tpm to load the plugin
set -g @plugin 'tmux-plugins/tmux-copycat'
# Copy/pasting with vimium/vimperator like hints.
set -g @plugin 'Morantron/tmux-fingers'
# Show no compact hints with format [xx]
set -g @fingers-compact-hints 0
# Show no compat hint on the left
set -g @fingers-hint-position-nocompact 'left'
# Restore last saved tmux environment when tmux is started.
set -g @continuum-restore 'on'
# Restore additional processes
set -g @resurrect-processes 'vi vim nvim emacs man less more tail top htop irssi weechat mutt ssh'
# Restore vim/neovim sessions
# - recommended: vim's vim-obsession plugin
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
# Restore content panes
# - set -g default-command must not contain && or || for this to work
# - Do not capture content panes, to avoid RAM hogs (https://stackoverflow.com/a/34914876/219728)
# set -g @resurrect-capture-pane-contents 'on'
################################################################################
# TMUX plugin manager.
################################################################################
# Install TPM
setenv -g TMUX_PLUGIN_MANAGER_PATH "$HOME/.tmux/plugins/"
if "test ! -d $HOME/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm && \
$TPM/.tmux/plugins/tpm/bin/install_plugins'"
# Initialize plugin manager
# - Keep this line as the last line of the tmux.conf file
run '~/.tmux/plugins/tpm/tpm'