zsh: Change cursor shape for vi modes

This commit is contained in:
Marty Oehme 2023-12-30 21:21:08 +01:00
parent e2f77e6faa
commit a5727c135b
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -151,6 +151,26 @@ bindkey "^[." insert-last-word
bindkey -v
# remove the delay for switching modes
export KEYTIMEOUT=1
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[2 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[6 q'
fi
}
zle -N zle-keymap-select
# Use beam shape cursor on startup.
_fix_cursor() {
echo -ne '\e[6 q'
}
precmd_functions+=(_fix_cursor)
# space puts a space, even in cmd mode
bindkey -a ' ' magic-space
# always allow backspace/delete to remove letters