dotfiles/.config/zsh/zkeys
tastytea cd9e60cb5b
Rename some Zsh files
No reason to keep the dot.
2022-03-18 23:22:00 +01:00

69 lines
2.1 KiB
Bash

#-*- mode: shell-script; -*-
# Keybindings - from zshwiki.org
# 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]}
# setup key accordingly
[[ -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]}" 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
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
function zle-line-init () {
if [[ "${TERM}" != "linux" ]] && [[ "${TERM}" != "dumb" ]]
then
echoti smkx
fi
}
function zle-line-finish () {
if [[ "${TERM}" != "linux" ]] && [[ "${TERM}" != "dumb" ]]
then
echoti smkx
fi
}
zle -N zle-line-init
zle -N zle-line-finish
bindkey '^[[1;5A' history-substring-search-up
bindkey '^[[1;5B' history-substring-search-down
bindkey '^H' backward-delete-word # C-BackSpace
bindkey '^[[3;5~' delete-word # C-Del
if [[ "${TERM}" =~ "^rxvt" ]]; then
bindkey '^[[3^' delete-word
bindkey '^[Od' backward-word
bindkey '^[Oc' forward-word
bindkey '^[Oa' history-substring-search-up
bindkey '^[Ob' history-substring-search-down
fi
bindkey '\eu' undo # Alt+u
bindkey '\eU' redo # Alt+Shift+u
bindkey '^q' push-line-or-edit