# vim: ft=zsh # # key binding configuration # # create a zkbd compatible hash # to add other keys to this hash, see: man 5 terminfo typeset -A key key[Home]=${terminfo[khome]} key[End]=${terminfo[kend]} key[Insert]=${terminfo[kich1]} 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[Backspace]=${terminfo[kbs]} key[CtrlLeft]=${terminfo[kLFT5]} key[CtrlRight]=${terminfo[kRIT5]} # setup keybindings! bindkey -v export KEYTIMEOUT=1 [[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line [[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line [[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode [[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" backward-delete-char [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history [[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char [[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char [[ -n "${key[Backspace]}" ]] && bindkey "${key[Backspace]}" backward-delete-char [[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" up-history [[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" down-history [[ -n "${key[CtrlLeft]}" ]] && bindkey "${key[CtrlLeft]}" backward-word [[ -n "${key[CtrlRight]}" ]] && bindkey "${key[CtrlRight]}" forward-word bindkey '^P' up-history bindkey '^N' down-history bindkey '^h' backward-delete-char bindkey '^w' backward-kill-word bindkey '^r' history-incremental-search-backward bindkey -a '/' history-incremental-search-backward # https://github.com/romkatv/zsh4humans/issues/7 bindkey "^[[H" beginning-of-line bindkey "^[[F" end-of-line # Finally, 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 function enter-editing-mode () { printf '%s' "${terminfo[smkx]}" } function exit-editing-mode () { printf '%s' "${terminfo[rmkx]}" } zle -N zle-line-init enter-editing-mode zle -N zle-line-finish exit-editing-mode fi