-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.conf
338 lines (280 loc) · 12.1 KB
/
header.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
# #AA0000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# #FFFFFF one_key_prefix is the only variable that performs a toggle between prefix and normal keys
%if "#{prefix_background}"
setenv -ghu prefix_background
%endif
%hidden prefix_background="#00d7d7"
setenv -gh prefix_background $prefix_background
%if "#{prefix_bg_on_light}"
setenv -ghu prefix_bg_on_light
%endif
%hidden prefix_bg_on_light="#d7d7ff"
setenv -gh prefix_bg_on_light $prefix_bg_on_light
# %hidden prefix_background="colour007,reverse"
# setenv -g prefix_background "colour003"
# You will probably be working in this mode for a whie, so a comfortable background color is important
%if "#{normal_background}"
setenv -ghu normal_background
%endif
# %hidden normal_background="colour007,reverse"
# %hidden normal_background="Teal,reverse"
%hidden normal_background="colour003" # orange # colour004 # blue
setenv -gh normal_background $normal_background
%if "#{normal_bg_on_light}"
setenv -ghu normal_bg_on_light
%endif
%hidden normal_bg_on_light="colour003" # colour004
setenv -gh normal_bg_on_light $normal_bg_on_light
# setenv -gh normal_background "colour008"
# showenv -gh normal_background # output: normal_background=colour009
# tmux display -p '#{prefix_key}'
# Escape is in charge of quiting edit mode in vi -- ModeChanged might help
# "prefix" key is out of mode by design
# When using "#{==:#{prefix_key},Escape}", it seems we could not expect much
# But if we dig deeper, we could still expect a pattern that avoids confusion and misuse
# without introducing new regular-use letter keys
# %hidden vim_in_charge_of_keystrokes=1
%hidden vim_in_charge_of_keystrokes=0
# Copying is prioritized
%hidden one_key_copy=1
# setenv -gh one_key_copy 1
# pane-focus-in triggering behaviour
# %hidden default_mode=1
%hidden default_mode=0
setenv -gh default_mode $default_mode
# #FFFFFF This is the only variable that performs the switch
# Comment out one and uncomment another to switch the key bindings policies
# #AA0000 Binding prefix_key to Escape
# Escape -> prefix-mode -> assist_key -> copy-mode
%hidden one_key_prefix=1 # enable "#{one_key_prefix}"
# #00AAAA Binding normal_key to Escape
# Escape -> copy-mode -> assist_key -> prefix-mode
# %hidden one_key_prefix=0 # disable "#{one_key_prefix}"
# setenv -gh one_key_prefix $one_key_prefix # could not enable "#{one_key_prefix}" on the first pass
%if '#{prefix_closed_loop}'
setenv -ghu prefix_closed_loop
%endif
%hidden prefix_closed_loop=0
# %hidden prefix_closed_loop=1
# %if "#{one_key_prefix}"
# setenv -ghu one_key_copy
# %endif # "#{one_key_prefix}"
# %if "#{one_key_prefix}"
# setenv -ghu one_key_prefix
# %endif # "#{one_key_prefix}"
# Copy-prefix-overlay/override/superposition-mode
%if "#{one_stage_policy}"
setenv -ghu one_stage_policy
%endif # "#{one_stage_policy}"
# %hidden one_stage_policy=1 # overlay mode is not considered
%hidden one_stage_policy=0 # copy-prefix-overlay/override/superposition-mode
setenv -gh one_stage_policy $one_stage_policy
%if "#{prefix_key}"
setenv -ghu prefix_key #
%endif # "#{prefix_key}"
%if "#{normal_key}"
setenv -ghu normal_key #
%endif # "#{normal_key}"
%if "#{toggle_key}"
setenv -ghu toggle_key #
%endif # "#{toggle_key}"
%hidden toggle_key="C-x"
setenv -gh toggle_key $toggle_key
%if "#{delegate_wincmd}"
setenv -ghu delegate_wincmd #
%endif # "#{delegate_wincmd}"
%hidden delegate_wincmd=1
# %hidden delegate_wincmd=0
setenv -gh delegate_wincmd $delegate_wincmd
%if "#{one_key_prefix}"
%hidden prefix_key="Escape" # "#{==:#{prefix_key},Escape}"
# prefix_key="Escape"
setenv -gh prefix_key $prefix_key # "unknown key:" error if no this setting
# %hidden prefix_key="`" # use M-` to input ` in the terminal or undefine it in terminal insert mode
# setenv -gh prefix_key $prefix_key
# prefix_key="`"
# set-option -g @prefix-key '`'
# Suppose you are in command mode in vim, Escape and Backtick are all occupied
# %hidden normal_key="Escape" #
# %hidden normal_key="C-[" # won't pass comparison with Escape
%hidden normal_key="`" # sh: syntax error: EOF in backquote substitution
# /bin/ash: if-shell -F "#{@is-vim}" send-keys: not found
# unknown key:
# bind -T root "$prefix_key" if-shell -F "#{@is-vim}" " send-keys $prefix_key " ' switch-client -T prefix '
# The following expression will generate \\$prefix_key
# bind -T root "$prefix_key" if-shell -F "#{@is-vim}" ' send-keys $prefix_key ' ' switch-client -T prefix '
# This is because
# 1. Backtick is a special key in shell
# 2. Read and re-applying it from vim/nvim side is not a trivial task
setenv -gh normal_key $normal_key # "unknown key:" error if no this setting
# set-option -g @normal-key 'Escape'
# display -p "# [0130] prefix_key: #{prefix_key}"
# display -p "# [0131] normal_key: #{normal_key}"
%else # "#{one_key_prefix}"
# Will evaluate at the second sourcing and enter it ? -- when set one_key_copy to false
# Set one_key_copy to false does not work, you must "unset" it to "" or 0
# %elif "#{one_key_copy}" # will erase $prefix_key ?
%hidden normal_key="Escape" # "#{==:#{normal_key},Escape}"
setenv -gh normal_key $normal_key # "unknown key:" error if no this setting
%hidden prefix_key="`" # use M-` to input ` in the terminal or unbind it in terminal insert mode
setenv -gh prefix_key $prefix_key
# display -p "# [0144] prefix_key: #{prefix_key}"
# display -p "# [0145] normal_key: #{normal_key}"
%endif # "#{one_key_prefix}"
# Diagram of the relationship between primary key and auxiliary key combination
# [Neovim/Terminal](mode_toggle)
# / \
# Escape Assist
# prefix-mode <-- [prefix_key] ]prefix_key[ <-- "#{==:#{normal_key},Escape}"
# \/
# /\
# copy-mode <-- ]normal_key[ [normal_key] <-- "#{==:#{prefix_key},Escape}"
#
# %if '#{!=:#{prefix_key},#{normal_key}}'
%if "#{==:#{prefix_key},Escape}" # #AA0000 Initialization
%hidden escape_key="$prefix_key"
%hidden assist_key="$normal_key"
# %hidden normal_enter="" # initializing
# Pseudo code, prototyes
# %hidden bind_escape_on_root="
# bind -T root '$escape_key' \"$prefix_enter\" # $prefix_enter is not defined at this moment
# "
# %hidden bind_escape_on_prefix="
# bind -T prefix '$escape_key' \"$prefix_quit\"
# "
%elif "#{==:#{normal_key},Escape}" # #00AAAA
%hidden escape_key="$normal_key"
%hidden assist_key="$prefix_key"
# %hidden bind_escape_on_root="
# bind -T root '$escape_key' \"$normal_enter\"
# "
# %hidden bind_escape_on_prefix="
# bind -T prefix '$escape_key' \"$normal_prefix\"
# "
%endif # who is Escape
# %endif # %if '#{!=:#{prefix_key},#{normal_key}}'
%if '#{!=:#{one_stage_policy},1}'
%hidden assist_key=
%endif
%if "#{&&:#{==:#{prefix_key},Escape},#{==:#{assist_key},}}" # #AA0000
%hidden normal_key=
setenv -ghu normal_key
%elif "#{&&:#{==:#{normal_key},Escape},#{==:#{assist_key},}}" # #00AAAA
%hidden prefix_key=
setenv -ghu prefix_key
%endif # who is Escape
%if "#{||:#{==:#{escape_key},},#{==:#{assist_key},}}"
%hidden one_key_is_empty=1
%endif
%if "#{&&:#{==:#{escape_key},},#{==:#{assist_key},}}"
%hidden both_keys_are_empty=1
%endif
%if "#{&&:#{==:#{one_stage_policy},1},#{one_key_is_empty}}"
%hidden should_include_00=1
%endif
%if "#{&&:#{!=:#{one_stage_policy},1},#{both_keys_are_empty}}"
%hidden should_include_01=1
%endif
%if "#{||:#{==:#{should_include_00},1},#{==:#{should_include_01},1}}"
%hidden should_include=1
%endif
%if "#{#{==:#{one_stage_policy},1}?#{||:#{==:#{escape_key},},#{==:#{assist_key},}},#{&&:#{==:#{escape_key},},#{==:#{assist_key},}}}"
%hidden heaer_included=1
%else
%hidden heaer_included=0
%endif
display -p "# [0220] prefix_key: #{prefix_key}"
display -p "# [0221] normal_key: #{normal_key}"
display -p "# [0223] escape_key: #{escape_key}"
display -p "# [0224] assist_key: #{assist_key}"
set -su command-alias[00]
set -su command-alias[01]
set -su command-alias[02]
set -su command-alias[03]
set -su command-alias[04]
set -su command-alias[05]
set -su command-alias[06]
set -su command-alias[07]
set -su command-alias[08]
set -su command-alias[09]
set -su command-alias[10]
set -su command-alias[11]
set -su command-alias[12]
set -su command-alias[13]
set -su command-alias[14]
set -su command-alias[15]
set -su command-alias[16]
set -su command-alias[17]
set -su command-alias[18]
setenv -ghu alias_index_00
setenv -ghu alias_index_01
setenv -ghu alias_index_02
setenv -ghu alias_index_03
setenv -ghu alias_index_04
setenv -ghu alias_index_05
setenv -ghu alias_index_06
setenv -ghu alias_index_07
setenv -ghu alias_index_08
setenv -ghu alias_index_09
setenv -ghu alias_index_10
setenv -ghu alias_index_11
setenv -ghu alias_index_12
setenv -ghu alias_index_13
setenv -ghu alias_index_14
setenv -ghu alias_index_15
setenv -ghu alias_index_16
setenv -ghu alias_index_17
setenv -ghu alias_index_18
# C-[, C-3, and Alt-[key] in nvim euqals to Esc. So you can not quit vim insert mode normally if entered
# [alt + single-normal-mode-key](https://vi.stackexchange.com/questions/300/other-ways-to-exit-insert-mode-besides-escape)
# bind -n 'C-[' copy-mode
unbind -n 'C-['
# For copy-mode-vi
# bind -T copy-mode Escape send-keys -X cancel
# bind -T copy-mode-vi Escape send-keys -X clear-selection
# unbind -T copy-mode Escape
# unbind -T copy-mode-vi Escape
# The following code will run after the first run of the conig file
# So, it will remove Escape key settings set in the first run -- it might not be what you want
# if -b '[ "$prefix_key" == "Escape" ]' \
# 'unbind -n ` ; unbind -T prefix `' \
# 'unbind -n Escape ; unbind -T prefix Escape'
# https://superuser.com/questions/1788219/tmux-if-else-endif-syntax-misbehaving-when-using-a-string-comparison-statemen
# No quotes, no spaces inside format, and double quotes outside format
# %if "#{==:#{prefix_key},Escape}"
unbind -n `
unbind -T prefix `
%if "#{prefix_key}"
unbind -n "$prefix_key"
unbind -T prefix "$prefix_key"
%endif # "#{prefix_key}"
# %else
unbind -n Escape
unbind -T prefix Escape
%if "#{normal_key}"
unbind -n "$normal_key"
unbind -T prefix "$normal_key"
%endif
# %endif
# bind -n 'M-Up' copy-mode
# bind -n 'M-s' copy-mode
# vim help use C-] to jump
# bind -n 'C-]' copy-mode
# unbind -n 'C-]'
# unbind -n 'C-c'
# https://unix.stackexchange.com/questions/293746/tmux-how-to-bind-a-key-to-enter-in-vi-mode-and-search-backwards
# bind -n M-s copy-mode
# bind -n M-Up copy-mode
# C-3, C-\[ equal to 'Escape'. You don't want to use it
# How to quit insert mode under this circumstance? quit tmux copy-mode and press F1
# C-\[ equals Esc
# bind -n C-\[ copy-mode
unbind C-b
display -p "$XDG_CONFIG_HOME/tmux/header.conf loaded"
display -p "one_stage_policy == #{one_stage_policy}"
display -p "heaer_included == #{heaer_included}"
display -p "should_include_00 == #{should_include_00}"
display -p "should_include_01 == #{should_include_01}"
display -p "should_include == #{should_include}"
%hidden header_loaded=1
# #AA0000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%