2021-07-08 16:52:07 +00:00
|
|
|
#
|
2019-10-31 23:18:00 +00:00
|
|
|
# key bindings
|
2021-07-08 16:52:07 +00:00
|
|
|
#
|
2019-10-31 23:18:00 +00:00
|
|
|
|
2019-11-05 06:18:59 +00:00
|
|
|
# set emacs mode
|
|
|
|
bindkey -e
|
|
|
|
|
2019-10-31 23:18:00 +00:00
|
|
|
# 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
|
2019-11-05 06:18:11 +00:00
|
|
|
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
|
|
|
|
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
|
|
|
|
|
2019-10-31 23:18:00 +00:00
|
|
|
|
2019-11-05 06:19:52 +00:00
|
|
|
# Finally, make sure the terminal is in application mode, when zle is
|
|
|
|
# active. Only then are the values from $terminfo valid.
|
2019-10-31 23:18:00 +00:00
|
|
|
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
|