-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwincmd.conf
189 lines (169 loc) · 10.5 KB
/
wincmd.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
# if '[ -s "$XDG_CONFIG_HOME/tmux/header.conf" ]' \
# {
# %if "#{||:#{&&:#{escape_key},#{assist_key}},#{&&:#{!=:#{one_stage_policy},1},#{||:#{escape_key},#{assist_key}}}"
# %if "#{&&:#{escape_key},#{assist_key}}"
# %else
# %if "#{#{==:#{one_stage_policy},1}?#{||:#{==:#{escape_key},},#{==:#{assist_key},}},#{&&:#{==:#{escape_key},},#{==:#{assist_key},}}}"
%if "#{&&:#{should_include},#{!=:#{header_loaded},1}}"
source "$XDG_CONFIG_HOME/tmux/header.conf"
%endif
# } {
# confirm-before -p "[0012] $XDG_CONFIG_HOME/tmux/header.conf is not a valid file. Kill server ? (y/n)" kill-server
# }
# https://superuser.com/questions/1601701/tmux-how-to-move-current-pane-to-far-left-right-up-down-like-in-vim
# move pane to the far right/left/bottom/top
# b -- back, f[h/v] -- full height/width
# bind C-H splitw -fhb \; swapp -t ! \; killp -t !
# bind C-L splitw -fh \; swapp -t ! \; killp -t !
# bind C-J splitw -fv \; swapp -t ! \; killp -t !
# bind C-K splitw -fvb \; swapp -t ! \; killp -t !
# Do it in prefix binding generally
%hidden copy_cancel="
# if-shell -F '#{is-border}' {} {
if-shell -F '#{pane_in_mode}' ' send-keys -X cancel '
# }
"
bind -T prefix n next-window \; display-panes -N
bind -T prefix e new-window
%if "#{prefix_closed_loop}"
%hidden loop_operation="
# if-shell -F '#{@is-float}' {} {
$prefix_enter
# }
"
%else
%hidden loop_operation="$color_terminal"
%endif
%if "#{delegate_wincmd}"
# Let vim default shortcuts take precedence
# bind -T prefix r "if-shell -F '#{@is-vim}' ' send-keys C-w C-R ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation" # always brings me surprises
bind -T prefix r "if-shell -F '#{@is-vim}' ' send-keys C-w C-R ' \; $loop_operation"
# bind -T prefix x "if-shell -F '#{@is-vim}' ' send-keys C-w C-X ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation" # always brings me surprises
bind -T prefix x "if-shell -F '#{@is-vim}' ' send-keys C-w C-X ' \; $loop_operation"
# bind -T prefix v if-shell -F '#{@is-vim}' ' send-keys C-w v ' \; set -g window-active-style bg=terminal
bind -T prefix v "if-shell -F '#{@is-vim}' ' send-keys C-w v ' $loop_operation"
# bind -T prefix n if-shell -F '#{@is-vim}' ' send-keys C-w n ; set -g window-active-style bg=terminal '
# bind -T prefix n next-window \; select-pane -t '#{pane_id}' \; set -p -t '#{pane_id}' window-active-style bg=terminal
# bind -T prefix n next-window \; select-pane -t '#{pane_id}' -P bg=terminal \; set -p -t '#{pane_id}' window-active-style bg=terminal
# bind -T prefix n next-window
# bind -T prefix n next-window \; select-pane -t '#{active_pane}' \; set -p -t '#{active_pane}' window-active-style bg=terminal
bind -T prefix s if-shell -F '#{@is-vim}' ' send-keys C-w s '
# bind -T prefix c if-shell -F '#{@is-vim}' ' send-keys C-w c ' ' new-window '
bind z resize-pane -Z \; run-shell -C color_terminal
# bind z run-shell 'tmux resize-pane -Z; tmux refresh-client -S'
# bind z resize-pane -Z \; refresh-client -S
# bind z set -g pane-active-border-style 'fg=colour116,bg=default' \; resize-pane -Z
# bind x confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind -T prefix c "
if-shell -F '#{@is-vim}' {
$copy_cancel
send-keys C-w c
} {
confirm-before -p 'kill-pane #P? (y/n)' kill-pane
}
$loop_operation
# run -C '$color_terminal' # make bindings easy to read
# The reason the color_terminal can be directly use here is that command aliases have been completely initialized
# color_terminal # static expansion like $color_terminal_impl
# $color_terminal # also work ?
"
unbind h
# bind -T prefix h "if-shell -F '#{@is-vim}' { $copy_cancel \n send-keys C-w h \n } { select-pane -L \n } \; $loop_operation"
bind -T prefix h "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -L \n } { \n send-keys C-w h \n } \; $loop_operation"
unbind Left
# bind -T prefix Left "if-shell -F '#{@is-vim}' ' send-keys C-w h ' ' select-pane -L ' \; $loop_operation"
bind -T prefix Left "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -L \n } { \n send-keys C-w h \n } \; $loop_operation"
unbind j
# bind -T prefix j "if-shell -F '#{@is-vim}' ' send-keys C-w j ' ' select-pane -D ' \; $loop_operation"
bind -T prefix j "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -D \n } { \n send-keys C-w j \n } \; $loop_operation"
unbind Down
# bind -T prefix Down "if-shell -F '#{@is-vim}' ' send-keys C-w j ' ' select-pane -D ' \; $loop_operation"
bind -T prefix Down "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -D \n } { \n send-keys C-w j \n } \; $loop_operation"
unbind k
# bind -T prefix k "if-shell -F '#{@is-vim}' ' send-keys C-w k ' ' select-pane -U ' \; $loop_operation"
bind -T prefix k "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -U \n } { \n send-keys C-w k \n } \; $loop_operation"
unbind Up
# bind -T prefix Up "if-shell -F '#{@is-vim}' ' send-keys C-w k ' ' select-pane -U ' \; $loop_operation"
bind -T prefix Up "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -U \n } { \n send-keys C-w k \n } \; $loop_operation"
unbind l
# bind -T prefix l if-shell -F '#{pane_in_mode}' ' select-pane -R ' { if-shell -F '#{@is-vim}' ' send-keys C-w l ' ' select-pane -R ' }
# bind -T prefix l if-shell -F '#{@is-vim}' ' send-keys C-w l ' ' select-pane -R ' # won't work in copy-prefix-overlay/override/superposition-mode
# bind -T prefix l "if-shell -F '#{@is-vim}' { $copy_cancel \n send-keys C-w l } { select-pane -R \n } \; $loop_operation"
bind -T prefix l "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -R \n } { \n send-keys C-w l \n } \; $loop_operation"
unbind Right
# bind -T prefix Right "if-shell -F '#{@is-vim}' ' send-keys C-w l ' ' select-pane -R ' \; $loop_operation"
bind -T prefix Right "if-shell -F '#{||:#{pane_in_mode},#{==:#{@is-vim},}}' { select-pane -R \n } { \n send-keys C-w l \n } \; $loop_operation"
# bind -T prefix H if-shell -F '#{pane_in_mode}' ' splitw -fhb \; swapp -t ! \; killp -t ! ' { if-shell -F '#{@is-vim}' ' send-keys C-w H ' end-keys splitw -fhb \; swapp -t ! \; killp -t ! ' }
bind -T prefix H "if-shell -F '#{@is-vim}' ' send-keys C-w H ; send-keys C-w +50 ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation"
bind -T prefix L "if-shell -F '#{@is-vim}' ' send-keys C-w L ; send-keys C-w -50 ' ' splitw -fh \; swapp -t ! \; killp -t ! ' \; $loop_operation"
bind -T prefix J "if-shell -F '#{@is-vim}' ' send-keys C-w J ' ' splitw -fv \; swapp -t ! \; killp -t ! ' \; $loop_operation"
bind -T prefix K "if-shell -F '#{@is-vim}' ' send-keys C-w K ' ' splitw -fvb \; swapp -t ! \; killp -t ! ' \; $loop_operation"
# run -C "bind -T prefix h if-shell -F \"#{\@is-vim}\" \" send-keys C-w h ; set -g window-active-style bg=terminal \""
# unbind Enter
%else
# bind -T prefix r "if-shell -F '#{@is-vim}' ' ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation" # always brings me surprises
# bind -T prefix x "if-shell -F '#{@is-vim}' ' ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation" # always brings me surprises
bind -T prefix v "if-shell -F '#{@is-vim}' ' send-keys v ' $loop_operation"
# bind h select-pane -L
# bind l select-pane -R
# bind j select-pane -D
# bind k select-pane -U
# bind -r h select-pane -L
# bind -r l select-pane -R
# bind -r j select-pane -D
# bind -r k select-pane -U
# bind -r k select-pane -U\; refresh-client -S
# bind -r j select-pane -D\; refresh-client -S
# bind -r l select-pane -R\; refresh-client -S
# bind -r h select-pane -L\; refresh-client -S
unbind h
# -r does not work on current tmux 3.4
# bind -T prefix h select-pane -L
bind -T prefix h "if-shell -F '#{@is-vim}' ' send-keys h ' ' select-pane -L ' \; $loop_operation"
unbind Left
bind -T prefix Left "if-shell -F '#{@is-vim}' ' send-keys Left ' ' select-pane -L ' \; $loop_operation"
unbind l
# bind -T prefix l select-pane -R
bind -T prefix l "if-shell -F '#{@is-vim}' ' send-keys l ' ' select-pane -R ' \; $loop_operation"
unbind Right
bind -T prefix Right "if-shell -F '#{@is-vim}' ' send-keys Right ' ' select-pane -R ' \; $loop_operation"
unbind j
# bind -T prefix j select-pane -D
bind -T prefix j "if-shell -F '#{@is-vim}' ' send-keys j ' ' select-pane -D ' \; $loop_operation"
unbind Down
bind -T prefix Down "if-shell -F '#{@is-vim}' ' send-keys Down ' ' select-pane -D ' \; $loop_operation"
unbind k
# bind -T prefix k select-pane -U
bind -T prefix k "if-shell -F '#{@is-vim}' ' send-keys k ' ' select-pane -U ' \; $loop_operation"
unbind Up
bind -T prefix Up "if-shell -F '#{@is-vim}' ' send-keys Up ' ' select-pane -U ' \; $loop_operation"
# unbind Left
# bind -T prefix Left select-pane -L
# unbind Right
# bind -T prefix Right select-pane -R
# unbind Down
# bind -T prefix Down select-pane -D
# unbind Up
# bind -T prefix Up select-pane -U
# bind H splitw -fhb \; swapp -t ! \; killp -t !
bind -T prefix H "if-shell -F '#{@is-vim}' ' send-keys H ' ' splitw -fhb \; swapp -t ! \; killp -t ! ' \; $loop_operation"
# bind L splitw -fh \; swapp -t ! \; killp -t !
bind -T prefix L "if-shell -F '#{@is-vim}' ' send-keys L ' ' splitw -fh \; swapp -t ! \; killp -t ! ' \; $loop_operation"
# bind J splitw -fv \; swapp -t ! \; killp -t !
bind -T prefix J "if-shell -F '#{@is-vim}' ' send-keys J ' ' splitw -fv \; swapp -t ! \; killp -t ! ' \; $loop_operation"
# bind K splitw -fvb \; swapp -t ! \; killp -t !
bind -T prefix K "if-shell -F '#{@is-vim}' ' send-keys K ' ' splitw -fvb \; swapp -t ! \; killp -t ! ' \; $loop_operation"
bind -T prefix c "
if-shell -F '#{@is-vim}' {
$copy_cancel
send-keys c
} {
confirm-before -p 'kill-pane #P? (y/n)' kill-pane
}
$loop_operation
# run -C '$color_terminal' # make bindings easy to read
# The reason the color_terminal can be directly use here is command aliases have been completely initialized
# color_terminal # static expansion like $color_terminal_impl
# $color_terminal # also work ?
"
%endif