49 lines
1.7 KiB
Bash
49 lines
1.7 KiB
Bash
|
# key bindings
|
||
|
|
||
|
# create a zkbd compatible hash;
|
||
|
# to add other keys to this hash, see: man 5 terminfo
|
||
|
typeset -g -A key
|
||
|
|
||
|
#key[Home]="${terminfo[khome]}"
|
||
|
#key[End]="${terminfo[kend]}"
|
||
|
#key[Insert]="${terminfo[kich1]}"
|
||
|
key[Backspace]="${terminfo[kbs]}"
|
||
|
key[Delete]="${terminfo[kdch1]}"
|
||
|
key[Up]="${terminfo[kcuu1]}"
|
||
|
key[Down]="${terminfo[kcud1]}"
|
||
|
key[Left]="${terminfo[kcub1]}"
|
||
|
key[Right]="${terminfo[kcuf1]}"
|
||
|
key[PageUp]="${terminfo[kpp]}"
|
||
|
key[PageDown]="${terminfo[knp]}"
|
||
|
key[ShiftTab]="${terminfo[kcbt]}"
|
||
|
|
||
|
# setup history search
|
||
|
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
||
|
zle -N up-line-or-beginning-search
|
||
|
zle -N down-line-or-beginning-search
|
||
|
|
||
|
# key bindings
|
||
|
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
|
||
|
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
|
||
|
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search
|
||
|
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
|
||
|
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" up-line-or-history
|
||
|
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" down-line-or-history
|
||
|
[[ -n "${key[ShiftTab]}" ]] && bindkey -- "${key[ShiftTab]}" reverse-menu-complete
|
||
|
|
||
|
# make sure the terminal is in application mode when zle is active
|
||
|
# only then are the values from $terminfo valid
|
||
|
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
|
||
|
autoload -Uz add-zle-hook-widget
|
||
|
zle_application_mode_start() {
|
||
|
echoti smkx
|
||
|
}
|
||
|
zle_application_mode_stop() {
|
||
|
echoti rmkx
|
||
|
}
|
||
|
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
|
||
|
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
|
||
|
fi
|
||
|
|
||
|
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2
|