-
Notifications
You must be signed in to change notification settings - Fork 1
/
.tmux.conf
249 lines (230 loc) · 10.6 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
################################################################################
# Tmux Configuration
################################################################################
#
# Tmux (and in general tabs/panes) interaction is based on the Alt key.
# The Super/Windows key is used by Openbox/Desktop interaction.
# And the Ctrl key for each app interaction.
#
# Main keys
# ---------
#
# Alt+x : Tmux Prefix
# Alt+: : Mode Command/Prompt
# Alt+z/c : Mode Copy
# Alt+p : Paste (from clipboard)
# Alt+- : Split Horizontal
# Alt+| : Split Vertical
# Alt+q : Quit/Detach
# Alt+t : New tab/window
# Alt-r : Rename current tab/window
# Alt+b : Break current pane into its own tab/window
# Alt+m : Mark/Select current pane
# Alt+s : Swap marked pane with current one
# Alt+j : Join marked pane with current one
# Alt+g : Group/Sync panes
# Alt+d : Display pane numbers and select
# Alt+e : Go to last pane
# Alt+w : Go to last window/tab
# Alt+f : Find a window by name
# Alt+F : TODO: Files?
# Alt+u : TODO: URLs?
# Alt+l : TODO: Lines?
# Alt+Space : Toggle maximized
#
# Navigation with Arrows
# ----------------------
#
# Alt+Arrows : Navigate between panes (with Vim integration)
# Alt+Shift+Left/Right : Navigate between tabs/windows
# Alt+Shift+Up/Down : Move current tab/window to the left or right
#
# In Copy Mode
# ------------
#
# s : Search up
# S : Search down
# y : Yank selection (also to clipboard)
# Ctrl+Up/Down : Scroll
#
# Clipboard integration
# ---------------------
#
# We should match vim setup (and EasyClip):
# vim unnamed -> xclip -selection primary (*)
# vim unnamedplus -> xclip -selection clipboard
#
# (*) unnamed/primary breaks r visual mode in Vim because the visually selected text is
# added to unnamed/primary (overwritting last yanked) and r on visual mode just replaces
# the selected text with its own.
#
# We use unnamedplus/clipboard:
# y on vim or y on tmux -> save to clipboard
# p on vim or <M-p> on tmux -> paste from clipboard
#
# <C-c> or copy on X-apps -> save to clipboard
# <S-C-v> on Terminator -> paste from clipboard
#
# select with mouse -> save to primary
# paste with middle mouse -> paste from primary (*)
#
# (*) A special paste for Vim in normal mode could be necessary (<C-v>?), but it tirns
# out that paste with middle mouse is magically pasted in Vim too.. great!
#
# Mouse Intergation
# -----------------
#
# Click to select panes and tabs/windows
# Scroll pane with wheel
# Resize panes draging borders
#
# TODO
# ----
#
# https://github.com/tmux-plugins/tmux-logging
# https://github.com/tmux-plugins/tmux-continuum
#
################################################################################
# Prefix
set -g prefix M-x
unbind C-b
bind M-x send-prefix
# Mouse Integration
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
# Main options and look&feel
set -g xterm-keys on
set -g status-justify left # centre discarded
set -g history-limit 5000
set -g display-time 10000 # time (ms) to show info in the bar (it's removed when a key is pressed)
set -g display-panes-time 10000 # time (ms) to show panes id (they're removed when a key is pressed)
set -g escape-time 0 # to avoid delays using escape in vim
set -g mode-keys vi
set -g base-index 1
set -g pane-base-index 1
set -g focus-events on
set -g visual-bell off # avoid annoying bells (with tmux-resurrect)
set -g other-pane-height 15 # lines of the non-main windows of main-horizontal layout
set -g status on # on by default, just in case
set -g status-left-length 40 # to avoid being truncated
set -g monitor-activity off # disabled because is too noisy when resizing terminator
set -g visual-activity off
set -g allow-rename off # annoying
set -g automatic-rename off # to save some CPU
set -g default-terminal "screen-256color"
set -g window-status-current-style fg=green,bg=black,bright
set -g window-status-activity-style fg=red,bg=black,bright
set -g status-right '#{?pane_synchronized,#[reverse]GROUP#[noreverse] ,} #{?client_prefix,#[reverse]Prefix#[noreverse] ,} %H:%M %d-%b' # to add visual help when prefix pressed
# Main keys
bind -n M-: command-prompt
bind -n M-q detach
bind -n M-t new-window -a -c "#{pane_current_path}"\;\
command-prompt 'rename-window %%'
bind -n M-r command-prompt 'rename-window %%'
bind -n M-| split-window -h -c "#{pane_current_path}"
bind -n M-- split-window -v -c "#{pane_current_path}"
bind -n M-S-Left prev
bind -n M-S-Right next
bind -n M-w last-window
bind -n M-e last-pane
bind -n M-d display-panes
bind -n M-f command-prompt "find-window -ZN -- '%%'"
bind -n M-1 select-window -t :1
bind -n M-2 select-window -t :2
bind -n M-3 select-window -t :3
bind -n M-4 select-window -t :4
bind -n M-5 select-window -t :5
bind -n M-6 select-window -t :6
bind -n M-7 select-window -t :7
bind -n M-8 select-window -t :8
bind -n M-9 select-window -t :9
bind -n M-0 select-window -t :0
bind -n M-S-Up swap-window -t -1 -d
bind -n M-S-Down swap-window -t +1 -d
bind -n M-m select-pane -m
bind -n M-j join-pane
bind -n M-b break-pane
bind -n M-s swap-pane
bind -n M-Space resize-pane -Z # not able to fwd to vim
bind -n M-g set-window-option synchronize-panes # toggles
# Copy-paste
bind -n M-c copy-mode
bind -n M-z copy-mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-pipe 'xclip -in -selection clipboard'
bind -n M-p run "xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer"
bind -T copy-mode-vi End send -X end-of-line
bind -T copy-mode-vi Home send -X start-of-line
bind -T copy-mode-vi C-Up send -X scroll-up
bind -T copy-mode-vi C-Down send -X scroll-down
bind -T copy-mode-vi C-Right send -X next-word
bind -T copy-mode-vi C-Left send -X previous-word
bind -T copy-mode-vi / command-prompt -p "(search up)" "send -X search-backward \"%%%\""
bind -T copy-mode-vi s command-prompt -p "(search up)" "send -X search-backward \"%%%\""
bind -T copy-mode-vi S command-prompt -p "(search down)" "send -X search-forward \"%%%\""
bind -T copy-mode-vi S-Left send -X begin-selection #\; cursor-left
bind -T copy-mode-vi S-Right send -X begin-selection #\; cursor-right
# Quick access to scroll
bind -n C-M-PageUp copy-mode -eu # it's not scroll, but page up
bind -T copy-mode-vi C-M-PageUp send -X scroll-up # ignored because the previous line... :-(
bind -T copy-mode-vi C-M-PageDown send -X scroll-down
# 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 M-Left if-shell "$is_vim" "send-keys M-Left" "select-pane -L"
bind-key -n M-Down if-shell "$is_vim" "send-keys M-Down" "select-pane -D"
bind-key -n M-Up if-shell "$is_vim" "send-keys M-Up" "select-pane -U"
bind-key -n M-Right if-shell "$is_vim" "send-keys M-Right" "select-pane -R"
# bind-key -n M-Space if-shell "$is_vim" "send-keys M-Space" "resize-pane -Z" # no :TmuxNavigation function for zoom
# bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# Plugins
set -g @plugin 'tmux-plugins/tpm'
# set -g @copycat_url_search '-n M-u'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-open' # To open selection as search or file
# set -g @plugin 'tmux-plugins/tmux-resurrect' # To keep tmux after restart
set -g @plugin 'tmux-plugins/tmux-continuum' # To continuous save of resurrect sessions
# tmux-resurrect config
set -g @resurrect-strategy-vim 'session' # To restore Vim sessions
set -g @resurrect-capture-pane-contents 'on' # To restore pane content/scroll
set -g @resurrect-save-shell-history 'off' # To restore commands history (annoying, see https://github.com/tmux-plugins/tmux-resurrect/issues/86)
set -g @resurrect-dir '~/.tmux/resurrect'
set -g @resurrect-save 'S' # Keybinding to Save content
set -g @resurrect-restore 'R' # Keybinding to Restore content
# tmux-continuim config
set -g @continuum-boot 'off' # no need to start tmux automatically
set -g @continuum-restore 'on' # autorestore when tmux started
# tmux-open config
set -g @open-G 'https://www.google.com/search?q=' # Not working?
set -g @open-C 'https://www.google.com/search?q='
set -g @shell_mode 'vi'
# set -g @plugin 'tmux-plugins/tmux-yank' # I don't want the bindings... just the copy_line.sh
# Unused
#
# bind -n M-f command-prompt "find-window '%%'" # M-f used to select files
# bind -n M-f run-shell "~/.tmux/plugins/tmux-copycat/scripts/copycat_mode_start.sh '(^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*'"
# bind -n M-F run-shell "~/.tmux/plugins/tmux-copycat/scripts/copycat_git_special.sh #{pane_current_path}"
# bind -n M-u run-shell "~/.tmux/plugins/tmux-copycat/scripts/copycat_mode_start.sh '(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*'"
# bind -n M-l run-shell -b ~/.tmux/plugins/tmux-yank/scripts/copy_line.sh
#
# bind S-Left swap-pane -L # not yet an option?
# bind S-Right swap-pane -R # not yet an option?
# bind S-Up swap-pane -U
# bind S-Down swap-pane -D
#
# bind -r M-Up resize-pane -U
# bind -r M-Down resize-pane -D
# bind -r M-Right resize-pane -R
# bind -r M-Left resize-pane -L
#
# bind -n M-DC join-pane -vdt :+.bottom
# bind -n M-IC join-pane -vs :+.bottom -p 20
#
# Use right window as a container for bottom panes (IDE-like) (never used, shortcut moved to vim)
# bind -n M-PageUp swap-pane -s :+.top -t :.bottom \; rotate-window -Ut :+
# bind -n M-PageDown swap-pane -s :+.bottom -t :.bottom \; rotate-window -Dt :+
#
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'