Repository navigation
Expand file tree
/
Copy pathtmux.conf
More file actions
431 lines (345 loc) · 14 KB
/
Copy pathtmux.conf
File metadata and controls
431 lines (345 loc) · 14 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
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# _
# | |_ _ __ ___ _ ___ __
# | __| '_ ` _ \| | | \ \/ /
# | |_| | | | | | |_| |> <
# \__|_| |_| |_|\__,_/_/\_\ ver 2.1
#
# written by Shotaro Fujimoto (https://github.com/ssh0)
#------------------------------------------------------------------------------
# General settings {{{
#------------------------------------------------------------------------------
# enable utf-8
# setw -g utf8 on
# max history limit
set -g history-limit 5000
# escape time
set -s escape-time 0
# Set the time in milliseconds for which the indicators shown by the
# display-pane command appear.
set -g display-panes-time 3000
# count windows stating with 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
# renumber the windows
set -g renumber-windows on
# Automatically set window title
setw -g automatic-rename on
# set-option -g default-command "exec reattach-to-user-namespace -l $SHELL"
# for Yazi's image preview to work correctly in tmux.
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
set -g extended-keys on
set -g extended-keys-format csi-u
set -as terminal-features '*:hyperlinks'
#---------------------------------------------------------------------------}}}
# Keybind Documentation {{{
#------------------------------------------------------------------------------
# I prefered using Alt key instead "Prefix + something".
# And I'm using xmonad, so these key-bindings are similar to xmonad's one.
# My xmonad config is here:
# https://github.com/ssh0/dotfiles/blob/master/.xmonad/ssh0-home/xmonad.hs
#
# Prefix key: ^g
#
# Abbreviation:
# - [key]
# - (key) <- with Alt (or in MacOS, Command key)
#
# Structure in one session:
#
# +----------------+
# | (←,→,h,l) ↓(num) OR click status bar ↓ (Enter)
# window1 <------> window2 window3 window4
# ===============================================================
# pane1 pane1 pane1 pane1
# ↕ (j,k)
# pane2 + - - pane2 - - - -> (pane2)
# | (L)
# (pane3) <- + pane3
# (H) ↓ (c) ↓ (C)
# x x
#
#
# In a window:
#
# +---------------+------------+
# |pane1 |pane3 |
# | | |
# | | |
# +---------------+ |
# |pane2 | |
# | | |
# | | |
# +---------------+------------+
#
# split pane:
# - vertically : (|)
# - horizontally : (-)
# select pane : (j),(k) OR click the pane with mouse
# shift pane : (J),(K)
# kill pane : (c)
# change layout : (Space)
# fullscreen : (f)
# resize pane:
# (a)
# ↑
# (,) ← + → (.)
# ↓ OR drag pane-border with mouse
# (z)
# join to another window : (H),(L)
# join to another window : [Alt+Shift+num]
#---------------------------------------------------------------------------}}}
# Unbind all keys & default key settings {{{
#------------------------------------------------------------------------------
unbind-key -a
# default key-bindings {{{
#======================#
bind-key C-z suspend-client
bind-key ! break-pane
bind-key '#' list-buffers
bind-key '$' command-prompt "rename-session '%%'"
bind-key , command-prompt "rename-window '%%'"
bind-key - delete-buffer
bind-key . command-prompt "move-window -t '%%'"
bind-key : command-prompt
bind-key \; last-pane
bind-key = choose-buffer
bind-key ? list-keys
bind-key D choose-client
bind-key L switch-client -l
bind-key [ copy-mode
bind-key ] paste-buffer
bind-key d detach-client
bind-key f command-prompt "find-window '%%'"
bind-key i display-message
bind-key q display-panes
bind-key s choose-session
bind-key w choose-window
bind-key '~' show-messages
bind-key PPage copy-mode -u
bind-key -r M-1 select-layout even-horizontal
bind-key -r M-2 select-layout even-vertical
bind-key -r M-3 select-layout main-horizontal
bind-key -r M-4 select-layout main-vertical
bind-key -r M-5 select-layout tiled
# }}}
#---------------------------------------------------------------------------}}}
# Keybind (normal mode) {{{
#------------------------------------------------------------------------------
# prefix key ^b -> ^g
set -g prefix C-g
bind-key C-g send-prefix
# vi like key binding
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
# if session has > 1 windows in current, kill-pane without confirmation.
# But confirm before killing pane when it is the last pane in the window.
bind-key -n M-c if "tmux display -p \"#{window_panes}\" | grep ^1\$" \
"confirm-before -p \"Kill the only pane in the window? It will kill this window too. (y/N)\" kill-pane" \
"kill-pane"
# if session has > 1 windows in current, kill-window without confirmation.
# But confirm before killing window when it is the last window in the session.
bind-key -n M-C if "tmux display -p \"#{session_windows}\" | grep ^1\$"\
"confirm-before -p \"Kill the only window in this session? It will kill the session too. (y/N)\" kill-window" \
"kill-window"
# split window (easily remember)
bind-key -n M-- split-window -v -c "#{pane_current_path}"
bind-key -n M-| split-window -h -c "#{pane_current_path}"
# vim like
bind-key s split-window -v -c "#{pane_current_path}"
bind-key v split-window -h -c "#{pane_current_path}"
# move between panes
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
bind-key -n M-Down select-pane -t :.+
bind-key -n M-Up select-pane -t :.-
# select the master pane
bind-key -n M-m select-pane -t :.1
# swap pane
bind-key -n M-J swap-pane -D
bind-key -n M-K swap-pane -U
bind-key -n M-S-Down swap-pane -D
bind-key -n M-S-Up swap-pane -U
# move the pane to the master pane
bind-key -n M-M swap-pane -d -t :.1
# swap pane to Alt+shift+number
bind-key -n M-! join-pane -t :1
bind-key -n M-'"' join-pane -t :2
bind-key -n M-'#' join-pane -t :3
bind-key -n M-'$' join-pane -t :4
bind-key -n M-% join-pane -t :5
bind-key -n M-& join-pane -t :6
bind-key -n M-"'" join-pane -t :7
bind-key -n M-( join-pane -t :8
bind-key -n M-) join-pane -t :9
# resize panes (xmonad like)
bind-key -n M-',' resize-pane -L 1
bind-key -n M-z resize-pane -D 1
bind-key -n M-a resize-pane -U 1
bind-key -n M-'.' resize-pane -R 1
# maximize pane ("f"ull screen)
bind-key -n M-f resize-pane -Z
# display-panes
bind-key -n M-q display-panes
# move between window
bind-key -n M-Right next-window
bind-key -n M-Left previous-window
# swap window
bind-key -n M-S-Right swap-window -t :+
bind-key -n M-S-Left swap-window -t :-
# next layout
bind-key -n M-Space next-layout
# switch windows Alt+number
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
# select-window by name typing
bind-key W command-prompt "select-window -t '%%'"
# create new window
bind-key -n M-Enter new-window -c "#{pane_current_path}"
# choose-tree
bind-key t choose-tree -w -Z -F "#{?pane_format,#[fg=colour229]#{pane_current_command} #[fg=colour247]#{pane_title},#{?window_format,#[fg=colour157]#{window_name}#{window_flags}#{?#{==:#{window_panes},1}, #{?#{!=:#{window_name},#{pane_current_command}},#[fg=colour11]#{pane_current_command} ,}#[fg=colour247]#{pane_title},},#[fg=colour238,bg=colour51]#{?session_grouped, (group #{session_group}: #{session_group_list}),}#{?session_attached, attached ,#[fg=colour238,bg=colour124] unattached }}}"
# Capture pane and open in Vim
bind-key C-c run 'tmux capture-pane -S -10240 -p > /tmp/tmux-capture.txt'\;\
new-window "vim + /tmp/tmux-capture.txt"
# Toggle status bar
bind-key -n M-0 set status
# ^b + r => reload config file
bind-key r source-file ~/.tmux.conf \; display "Reloaded!"
#---------------------------------------------------------------------------}}}
# Keybind (copy mode) {{{
#------------------------------------------------------------------------------
# v: select start with v (default Space)
bind-key -T copy-mode-vi v send-keys -X begin-selection
# V: select line
# bind-key -T vi-copy V select-line
# C-v: select rectangular
# bind-key -T vi-copy C-v rectangle-toggle
# y: yank
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# Y: yank line
# bind-key -T vi-copy Y copy-line
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
#---------------------------------------------------------------------------}}}
# Mouse settings {{{
#------------------------------------------------------------------------------
set -g mouse on
#---------------------------------------------------------------------------}}}
# Color {{{
#------------------------------------------------------------------------------
# use 256colors
set -g default-terminal screen-256color
# # pane border
# set -g pane-active-border-style fg=colour197,bg=colour235
# set -g pane-border-style fg=colour239,bg=colour235
# # window list
# setw -g window-status-style fg=white,bg=colour235
# # message line
# # set -g message-fg white
# # set -g message-bg colour197
# # set -g message-attr bright
# set -g message-command-style bg=colour255,fg=colour235
# set -g message-style bg=colour235,fg=colour255
# set -g mode-style bg=colour197,fg=colour235
#====================
# Name: Flexoki
# Variant: Light
# URL: https://stephango.com/flexoki
# Description: An inky color scheme for prose and code.
# Note: Color hexes in lower case to avoid tmux flag confusion
flexoki_black="#100f0f"
flexoki_base_950="#1c1b1a"
flexoki_base_900="#282726"
flexoki_base_850="#343331"
flexoki_base_800="#403e3c"
flexoki_base_700="#575653"
flexoki_base_600="#6f6e69"
flexoki_base_500="#878580"
flexoki_base_300="#b7b5ac"
flexoki_base_200="#cecdc3"
flexoki_base_150="#dad8ce"
flexoki_base_100="#e6e4d9"
flexoki_base_50="#f2f0e5"
flexoki_paper="#fffcf0"
flexoki_red="#d14d41"
flexoki_orange="#da702c"
flexoki_yellow="#d0a215"
flexoki_green="#879a39"
flexoki_cyan="#3aa99f"
flexoki_blue="#4385be"
flexoki_purple="#8b7ec8"
flexoki_magenta="#ce5d97"
flexoki_red_2="#af3029"
flexoki_orange_2="#bc5215"
flexoki_yellow_2="#ad8301"
flexoki_green_2="#66800b"
flexoki_cyan_2="#24837b"
flexoki_blue_2="#205ea6"
flexoki_purple_2="#5e409d"
flexoki_magenta_2="#a02f6f"
color_tx_1=$flexoki_black
color_tx_2=$flexoki_base_600
color_tx_3=$flexoki_base_300
color_bg_1=$flexoki_base_200
color_bg_2=$flexoki_base_100
color_ui_1=$flexoki_base_200
color_ui_2=$flexoki_base_300
color_ui_3=$flexoki_base_500
color_red=$flexoki_red
color_orange=$flexoki_orange
color_yellow=$flexoki_yellow
color_green=$flexoki_green
color_cyan=$flexoki_cyan
color_blue=$flexoki_blue
color_purple=$flexoki_purple
color_magenta=$flexoki_magenta
# status
set -g status-position top
set -g status on
set -g status-bg $color_bg_2
set -g status-justify "left"
set -g status-left-length "100"
set -g status-right-length "100"
# messages
set -g message-style "fg=$color_tx_1,bg=$color_bg_2,align=centre"
set -g message-command-style "fg=$color_tx_1,bg=$color_ui_2,align=centre"
# panes
set -g pane-border-style fg=$color_ui_2
set -g pane-active-border-style fg=$color_blue
# windows
setw -g window-status-activity-style fg=$color_tx_1,bg=$color_bg_1,none
setw -g window-status-separator " "
setw -g window-status-style fg=$color_tx_1,bg=$color_bg_1,none
# statusline
set -g status-left "#{?client_prefix,#[fg=#$flexoki_paper#,bg=#$color_red],#[fg=#$flexoki_paper#,bg=#$color_green]} #S #{?client_prefix,#[fg=#$color_red#,bg=#$color_bg_2],#[fg=#$color_green#,bg=#$color_bg_2]}#[fg=#$color_bg_2#,bg=#$color_bg_2] "
set -g status-right "#[fg=#$color_paper,bg=#$color_orange] #(echo #{pane_current_path} | sed 's#$HOME#~#g') "
# window-status
setw -g window-status-format "#[bg=#$color_bg_2,fg=#$color_tx_2] #I · #W "
setw -g window-status-current-format "#[bg=#$color_bg_2,fg=#$color_bg_1]#[bg=#$color_bg_1,fg=#$color_tx_1] #I ● #W #[bg=#$color_bg_2,fg=#$color_bg_1]"
# set -g status-left "#{?client_prefix,#[fg=#$flexoki_paper,bg=#$color_red],#[fg=#$flexoki_paper,bg=#$color_green]} ╭ #S #{?client_prefix,#[fg=#$color_red,bg=#$color_bg_2],#[fg=#$color_green,bg=#$color_bg_2]}╯#[fg=#$color_bg_2,bg=#$color_bg_2] "
# set -g status-right "#[fg=#$color_paper,bg=#$color_orange] ╭ #(echo #{pane_current_path} | sed 's#$HOME#~#g') ╯ "
# Modes
setw -g clock-mode-colour $color_blue
setw -g mode-style fg=$color_orange,bg=$color_tx_1,bold
#---------------------------------------------------------------------------}}}
# WM window title {{{
#------------------------------------------------------------------------------
# enable wm window titles
set -g set-titles on
# wm window title string (uses status bar variables)
set -g set-titles-string "#S - #W [#I/#{session_windows}] (#P/#{window_panes})"
#---------------------------------------------------------------------------}}}
# Status line {{{
#------------------------------------------------------------------------------
# source $HOME/.config/tmux/status_powerline.conf
# source $HOME/.config/tmux/status.conf
#---------------------------------------------------------------------------}}}