-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
241 lines (199 loc) · 8.49 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
## common config to copy around {{{
# ( vim: set ts=4 sw=4 et fdm=marker: )
## Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 2
# new-session -n $HOST -s main # new session main if no session specified
## Most compatible setting:
# set -g default-terminal "screen-256color"
# set -ga terminal-overrides ",*256col*:Tc"
set -g mouse on
set -g prefix C-a
setw -g mode-keys vi
set -g status-position top
set -sg escape-time 0
set -wg xterm-keys on
set -sg extended-keys always
set -as terminal-features 'xterm*:extkeys'
set -g allow-passthrough on
set -g focus-events on
# dim inactive panes
# set -g window-style 'bg=colour236'
# set -g window-active-style 'bg=color0'
bind v split-window -h -l 50% -c "#{pane_current_path}"
bind s split-window -v -l 50% -c "#{pane_current_path}"
bind n new-window
# easy mistakes
bind C-l last-window
# set mouse on with prefix m
bind m set -g mouse on \; display 'Mouse: ON'
# set mouse off with prefix M
bind M set -g mouse off \; display 'Mouse: OFF'
# {{{ tmux-navigator replacement
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?|docker)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || \
tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || \
($is_fzf && tmux send-keys C-j) || \
tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || \
($is_fzf && tmux send-keys C-k) || \
tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || \
tmux select-pane -R"
bind -n M-` if-shell "$is_vim" 'send-keys M-`' 'select-pane -l'
# navigate in copy mode as well
bind -T copy-mode-vi C-h select-pane -L
bind -T copy-mode-vi C-j select-pane -D
bind -T copy-mode-vi C-k select-pane -U
bind -T copy-mode-vi C-l select-pane -R
bind -r c-J resize-pane -D 5
bind -r c-K resize-pane -U 5
bind -r c-H resize-pane -L 5
bind -r c-L resize-pane -R 5
# quick switch with control + number: replaced with kitty keymap
# 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
set-window-option -g automatic-rename off
set-option -g set-titles off
bind O setw synchronize on \; display 'Synchronize on'
bind C-o setw synchronize off \; display 'Synchronize off'
bind C send-keys -R \; clear-history
bind C-c copy-mode
bind C-[ copy-mode
bind Escape run 'true'
bind C-v paste-buffer
bind C-] paste-buffer
bind C-z resize-pane -Z
bind N move-window -r \; display 'Renumbered' # renumber window
bind L move-pane -h -t '.-' # stack the adjacent pane horizontally
bind H move-pane -t '.-' # stack the adjacent pane vertically
bind A move-window -t 0 \; move-window -r
# copy mode
bind Enter copy-mode
bind b list-buffers
bind p paste-buffer
bind P choose-buffer
bind ? list-keys
# word separators for automatic word selection
setw -g word-separators ' @"=()[]'
setw -ag word-separators "'"
setw -g aggressive-resize off
# the following vi-copy bindings follow vim settings
bind -T edit-mode-vi Up send -X history-up
bind -T edit-mode-vi Down send -X history-down
bind -T copy-mode-vi Space send -X begin-selection
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi C-v run "tmux send -X rectangle-toggle; tmux send -X begin-selection"
bind -T copy-mode-vi [ send -X begin-selection
bind -T copy-mode-vi ] send -X copy-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi q send -X clear-selection
# Easy one hand copy & paste
bind -T copy-mode-vi c send -X copy-pipe-and-cancel
bind -T copy-mode-vi C send -X copy-pipe-and-cancel "tmux paste-buffer"
bind -T copy-mode-vi Y send -X copy-pipe-and-cancel "tmux paste-buffer"
# native regex search (copycat replacement)
bind / copy-mode \; send ?
# URL search
bind C-u copy-mode \; send -X search-backward "(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*"
# create session
bind C-c command-prompt -p new-session 'new-session -s %%'
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'
# session navigation
bind BSpace switch-client -l # move to last session
bind -n C-q last-window
# }}}
# CTRL-[SHIFT]-Tab is remapped to M-C-n/p in kitty
bind -n M-C-n next-window
bind -n M-C-p previous-window
# bind -n BTab last-window
# https://stackoverflow.com/a/55616731/714179
bind -n Home send Escape "OH"
bind -n End send Escape "OF"
# other useful things learned from https://github.com/gpakosz/.tmux/blob/master/.tmux.conf
# }}}
## if Italics needed, need to use "tmux":
## https://github.com/tmux/tmux/wiki/FAQ#i-dont-see-italics-or-italics-and-reverse-are-the-wrong-way-round
## https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95#the-right-way
# set -g default-terminal "tmux-256color"
## kitty terminfo has it all, but needs terminfo when using ssh
## https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-when-sshing-into-a-different-computer
set -g default-terminal "xterm-kitty"
# {{{ commands with external dependencies
# share session with gotty
bind-key c-t new-window -n "term readonly shareing" \
"ttyd -R tmux attach -t `tmux display -p '#S'`" \; \
split-window -h "ngrok http -bind-tls=true 7681"
# share with write
bind-key T new-window -n "term WRITABLE shareing" \
"ttyd -c jackieli:Tes9ting tmux attach -t `tmux display -p '#S'`" \; \
split-window -h "ngrok http 7681"
bind-key c-y run-shell "$HOME/.config/base16-shell-hooks/modify-cursor-color"
# }}}
# {{{ plugin settings
# tmux-yank: https://github.com/tmux-plugins/tmux-yank/blob/master/scripts/helpers.sh#L56
# mouse yank to system clipboard
set -g @yank_selection_mouse 'clipboard' # or 'primary' or 'secondary'
set -g @yank_action 'copy-pipe-and-cancel'
# override tmux-yank's default mouse yank: if copy-commande use
# copy-pipe-and-cancel, it'll drag and copy:
# https://github.com/tmux-plugins/tmux-yank/blob/master/yank.tmux#L51 We want
# to be able to drag again to reselect and copy -b to put in background; -d 1
# to delay 1 second
# TODO: new version of tmux use set -s copy-command 'pbcopy'
run -b -d 1 'tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear'
# search engine google
set -g @open-S 'https://www.google.com/search?q='
set -g @extrakto_fzf_tool $HOME/.fzf/bin/fzf
# display "$HOME/.fzf/bin/fzf $FZF_DEFAULT_OPTS"
set -g @extrakto_grab_area 'window full'
set -g @extrakto_split_size "15"
# set -g @extrakto_clip_tool "xsel --input --clipboard" # works better for nvim
set -g @extrakto_copy_key "tab"
set -g @extrakto_insert_key "enter"
set -g @jump-key 'j'
set -g @themepack 'powerline/default/gray'
# set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-processes 'false'
set -g @resurrect-save 'S'
set -g @emulate-scroll-for-no-mouse-alternate-buffer on
# set -g @named-snapshot-save 'C-m:main,M-n:other'
# set -g @named-snapshot-restore 'M:main,N:other'
# }}}
# {{{ List of plugins
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'
# set -g @plugin 'christoomey/vim-tmux-navigator' # using our own binding above
set -g @plugin 'tmux-plugins/tmux-open' # for open search or file
# set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank' # set up many yank commands
# set -g @plugin 'jackielii/extrakto'
set -g @plugin 'laktak/extrakto' # select word from screen
#set -g @plugin 'Morantron/tmux-fingers' # <prefix> F
set -g @plugin 'schasse/tmux-jump' # <prefix> [j]ump
set -g @plugin 'tmux-plugins/tmux-resurrect' # <prefix> <c-s>/<c-r> to save/restore
set -g @plugin 'nhdaly/tmux-better-mouse-mode' # for scrolling in less
# set -g @plugin 'spywhere/tmux-named-snapshot' # restore named sessions
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
# }}}