zsh vi mode, cursor style in normal and insert mode

This commit is contained in:
TheK4n 2022-11-19 21:41:00 +03:00
parent 2ddc04cd36
commit 4b05b6c8ec

View File

@ -14,7 +14,36 @@ WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word
PROMPT_EOL_MARK=""
# configure key keybindings
# Activate vim mode.
bindkey -v
# Change cursor shape for different vi modes.
zle-keymap-select() {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
# Use beam shape cursor on startup.
echo -ne '\e[5 q'
# Use beam shape cursor for each new prompt.
preexec() {
echo -ne '\e[5 q'
}
bindkey -M viins 'jk' vi-cmd-mode
bindkey ' ' magic-space # do history expansion on space
bindkey '^[[3;5~' kill-word # ctrl + Supr