summaryrefslogtreecommitdiff
path: root/user:hugues/GusBindings.zsh
blob: 25697971c102786bd016902fed874966dd9ee5e8 (plain)
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
##
## Part of configuration files for Zsh 4
## by Hugues Hiegel <hugues@hiegel.fr>
## 
## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS
##
## You are encouraged to use, modify, and redistribute
## these files with or without this notice.
## 

## Key bindings
#
# Lancez un chtit bindkey dans votre zsh pour voir... 
#

#set_keymap()
#{
#	main=$1
#	bindkey -A main $main
#}
## Vi-mode
#set_keymap viins

bindkey '^[[3~' delete-char			# delete
bindkey '^[[2~' overwrite-mode			# insert
bindkey '^[[A' up-line-or-history		# up
bindkey '^[[B' down-line-or-history		# down
bindkey '^[^[[A' history-search-backward	# META-up
bindkey '^[^[[B' history-search-forward		# META-down
bindkey '^[^[[C' forward-word			# ESC right
bindkey '^[^[[D' backward-word			# ESC left
bindkey '^[^[[3~' kill-region			# ESC del

test $TERM = 'rxvt' -o $TERM = 'xterm' -o $TERM = 'aterm' &&
{
	bindkey '^[[1~' beginning-of-line	# home
	bindkey '^[[4~' end-of-line		# end-of-line
	bindkey '^[Oc' forward-word		# CTRL right
	bindkey '^[Od' backward-word	# CTRL left
	bindkey '^[[3$' vi-set-buffer		# SHIFT del
	bindkey '^[Oa' history-search-backward	# CTRL UP
	bindkey '^[Ob' history-search-forward	# CTRL DOWN
	bindkey '^[OH' beginning-of-line	# home
	bindkey '^[OF' end-of-line		# end-of-line
}

#
# Sanity
#
#bindkey '^X#' set-mark-command
bindkey '^A' beginning-of-line
bindkey '^B' backward-char
bindkey '^D' delete-char-or-list
bindkey '^E' end-of-line
bindkey '^F' forward-char
bindkey '^G' send-break
bindkey '^H' backward-delete-char
bindkey '^I' expand-or-complete
bindkey '^J' accept-line # '\n' is considered as ^J
bindkey '^K' kill-line
bindkey '^L' clear-screen
bindkey '^M' accept-line
bindkey '^N' down-line-or-history
bindkey '^O' accept-line-and-down-history
bindkey '^P' up-line-or-history
bindkey '^Q' push-line-or-edit
bindkey '^R' history-incremental-search-backward
bindkey '^S' history-incremental-search-forward
bindkey '^T' transpose-chars
bindkey '^U' backward-kill-line
bindkey '^V' quoted-insert
bindkey '^W' backward-kill-word
bindkey '^X^B' vi-match-bracket
bindkey '^X^F' vi-find-next-char
bindkey '^X^J' vi-join
bindkey '^X^K' kill-buffer
bindkey '^X^N' infer-next-history
bindkey '^X^O' overwrite-mode
bindkey '^X^R' _read_comp
bindkey '^X^U' undo
bindkey '^X^V' vi-cmd-mode
#bindkey '^X^X' exchange-point-and-mark
bindkey '^X*' expand-word
bindkey '^X=' what-cursor-position
bindkey '^X?' _complete_debug
bindkey '^XC' _correct_filename
bindkey '^XG' list-expand
bindkey '^Xa' _expand_alias
bindkey '^Xc' _correct_word
bindkey '^Xd' _list_expansions
bindkey '^Xe' _expand_word
bindkey '^Xg' list-expand
bindkey '^Xh' _complete_help
bindkey '^Xm' _most_recent_file
bindkey '^Xn' _next_tags
bindkey '^Xr' history-incremental-search-backward
bindkey '^Xs' history-incremental-search-forward
bindkey '^Xt' _complete_tag
bindkey '^Xu' undo
bindkey '^X~' _bash_list-choices
bindkey '^Y' yank
bindkey '^[^D' list-choices
bindkey '^[^G' send-break
bindkey '^[^H' backward-kill-word
bindkey '^[^I' self-insert-unmeta
bindkey '^[^J' self-insert-unmeta
bindkey '^[^L' clear-screen
bindkey '^[^M' self-insert-unmeta
bindkey '^[^[[3~' kill-region
bindkey '^[^[[A' history-search-backward
bindkey '^[^[[B' history-search-forward
bindkey '^[^[[C' forward-word
bindkey '^[^[[D' backward-word
bindkey '^[^_' copy-prev-word
bindkey '^[ ' magic-space
bindkey '^[!' expand-history
bindkey "^['" set-mark-command
bindkey '^[$' spell-word
bindkey '^["' exchange-point-and-mark
bindkey '^[,' _history-complete-newer
bindkey '^[-' neg-argument
bindkey '^[.' insert-last-word
bindkey '^[/' _history-complete-older
bindkey '^[0' digit-argument
bindkey '^[1' digit-argument
bindkey '^[2' digit-argument
bindkey '^[3' digit-argument
bindkey '^[4' digit-argument
bindkey '^[5' digit-argument
bindkey '^[6' digit-argument
bindkey '^[7' digit-argument
bindkey '^[8' digit-argument
bindkey '^[9' digit-argument
bindkey '^[<' beginning-of-buffer-or-history
bindkey '^[>' end-of-buffer-or-history
bindkey '^[?' which-command
bindkey '^[A' accept-and-hold
bindkey '^[B' backward-word
bindkey '^[C' capitalize-word
bindkey '^[D' kill-word
bindkey '^[F' forward-word
bindkey '^[G' get-line
bindkey '^[H' run-help
bindkey '^[L' down-case-word
bindkey '^[N' history-search-forward
bindkey '^[OA' up-line-or-history
bindkey '^[OB' down-line-or-history
bindkey '^[OC' forward-char
bindkey '^[OD' backward-char
bindkey '^[P' history-search-backward
bindkey '^[Q' push-line-or-edit
bindkey '^[S' spell-word
bindkey '^[T' transpose-words
bindkey '^[U' up-case-word
bindkey '^[W' copy-region-as-kill
bindkey '^[[1~' beginning-of-line
bindkey '^[[2~' overwrite-mode
bindkey '^[[3~' delete-char
bindkey '^[[4~' end-of-line
bindkey '^[[5~' history-beginning-search-backward-end
bindkey '^[[6~' history-beginning-search-forward-end
bindkey '^[[A' up-line-or-history
bindkey '^[[B' down-line-or-history
bindkey '^[[C' forward-char
bindkey '^[[D' backward-char
bindkey '^[_' insert-last-word
bindkey '^[a' accept-and-hold
bindkey '^[b' backward-word
bindkey '^[c' capitalize-word
bindkey '^[d' kill-word
bindkey '^[f' forward-word
bindkey '^[g' get-line
bindkey '^[h' run-help
bindkey '^[l' down-case-word
bindkey '^[n' history-search-forward
bindkey '^[p' history-search-backward
bindkey '^[q' push-line
bindkey '^[s' spell-word
bindkey '^[t' transpose-words
bindkey '^[u' up-case-word
bindkey '^[w' copy-region-as-kill
bindkey '^[x' execute-named-cmd
bindkey '^[y' yank-pop
bindkey '^[z' execute-last-named-cmd
bindkey '^[|' vi-goto-column
bindkey '^[~' _bash_complete-word
bindkey '^[^?' backward-kill-word
bindkey '^\^[[A' up-history
bindkey '^\^[[B' down-history
bindkey '^\^[[C' forward-char
bindkey '^\^[[D' backward-char
bindkey '^_' undo
bindkey ' '-'~' self-insert
bindkey '^?' backward-delete-char
bindkey '\M-^@'-'\M-^?' self-insert

#
#

for keymap in viins vicmd emacs
do
	bindkey -M $keymap    '^[r' _rehash

	if ( __cmd_exists when )
	then
		bindkey -M $keymap -s '^[w' '^[Q when\n'
	fi

	if ( __cmd_exists tickets )
	then
		bindkey -M $keymap -s '^[t' '^[Q tickets\n'
		bindkey -M $keymap -s '^[T' '^[Q !?tickets\n'
	elif ( __cmd_exists todo )
	then
		bindkey -M $keymap -s '^[t' '^[Q todo\n'
		bindkey -M $keymap -s '^[T' '^[Q todo all -c\n'
	fi

	bindkey -M $keymap -s '^[c' '^[Q ./configure\n'
	bindkey -M $keymap -s '^[©' '^[Q !?configure\n'

	bindkey -M $keymap -s '^[m' '^[Q make\n'
	bindkey -M $keymap -s '^[M' '^[Q make\n'

	bindkey -M $keymap -s '^[l' '^[Q l\n'

	bindkey -M $keymap -s '^[ ' '\\ '

	bindkey -M $keymap -s '^[g' '^[Q git st .\n'
	bindkey -M $keymap -s '^[G' '^[Q git fetchall\n'

	#bindkey -M $keymap -s '^[E' '^[Q eval $( !! )'
	bindkey -M $keymap -s '^[E' '^A eval $( ^E )'

	#bindkey -M $keymap -s '^[S' '^[Q sudo !!'
	bindkey -M $keymap -s '^[S' '^A sudo ^E'

	bindkey -M $keymap -s '^[X' '^[Q kill -USR1 $$\n'

	bindkey -M $keymap -s '^[^[OA' 'up-line-or-history'
	bindkey -M $keymap -s '^[^[OB' 'down-line-or-history'
	bindkey -M $keymap -s '^[^[OC' 'forward-word'
	bindkey -M $keymap -s '^[^[OD' 'backward-word'

	bindkey -M $keymap '^[q' push-input
	bindkey -M $keymap '^[Q' push-input

	bindkey -M $keymap -s '^[R' '^[Q up_up ; sc blue ; __redefine_prompt\n^[xreset-prompt\n'
	bindkey -M $keymap -s '^[B' '^[Q __clear $(tput lines)\n'
done

# redefines push-line for vicmd
bindkey -M vicmd -s '^[q' 'i^[q'
bindkey -M vicmd -s '^[Q' 'i^[Q'

# Sets vicmd-mode vim-compliant
bindkey -M vicmd 'u' 'undo'
bindkey -M vicmd '^R' 'redo'
bindkey -M vicmd '^[j' 'history-search-forward'
bindkey -M viins '^[j' 'history-search-forward'
bindkey -M vicmd '^[k' 'history-search-backward'
bindkey -M viins '^[k' 'history-search-backward'


menuselect_vi-mode()
{
	# Sets menuselect vim-compliant
	bindkey -M menuselect 'j' 'down-line-or-history'
	bindkey -M menuselect 'k' 'up-line-or-history'
	bindkey -M menuselect 'h' 'backward-char'
	bindkey -M menuselect 'l' 'forward-char'
}

# Enters vi-cmd mode at each prompt
#zle-line-init() { zle vi-cmd-mode }
#zle -N zle-line-init

# Show the current keymap used
#zle-keymap-select()
#{
#	if [ "$KEYMAP" != "main" ]
#	then
#		__term_title " [$KEYMAP]"
#	else
#		__term_title
#	fi
#}

#zle -N zle-keymap-select
#zle -N zle-line-init zle-keymap-select ## CRASHES UPON MULTILINE COMMAND...