3 # create a zkbd compatible hash;
4 # to add other keys to this hash, see: man 5 terminfo
7 key[Home]=${terminfo[khome]}
9 key[End]=${terminfo[kend]}
10 key[Insert]=${terminfo[kich1]}
11 key[Delete]=${terminfo[kdch1]}
12 key[Up]=${terminfo[kcuu1]}
13 key[Down]=${terminfo[kcud1]}
14 key[Left]=${terminfo[kcub1]}
15 key[Right]=${terminfo[kcuf1]}
16 key[PageUp]=${terminfo[kpp]}
17 key[PageDown]=${terminfo[knp]}
19 # setup key accordingly
20 [[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
21 [[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
22 [[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
23 [[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
24 [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
25 [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
26 [[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
27 [[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
28 [[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
29 [[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
31 # Finally, make sure the terminal is in application mode, when zle is
32 # active. Only then are the values from $terminfo valid.
33 if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
34 function zle-line-init () {
35 printf '%s' "${terminfo[smkx]}"
37 function zle-line-finish () {
38 printf '%s' "${terminfo[rmkx]}"
41 zle -N zle-line-finish