Add different cursors for normal and insert mode

This commit is contained in:
Jakob Kofod Beyer 2018-03-01 16:24:36 +01:00 committed by GitHub
commit dfd12c1f8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,26 @@
# Updates editor information when the keymap changes.
# Updates editor information when the keymap changes, and changes the cursor.
function zle-keymap-select() {
if [[ $KEYMAP == vicmd ]]; then
echo -ne '\e[1 q'
elif [[ $KEYMAP == main ]] || [[ $KEYMAP == viins ]] || [[ $KEYMAP = '' ]]; then
echo -ne '\e[5 q'
fi
zle reset-prompt
zle -R
}
# Changes the cursor at a new line.
function zle-line-init() {
echo -ne '\e[5 q'
}
# Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() {
zle && zle -R
}
zle -N zle-keymap-select
zle -N zle-line-init
zle -N edit-command-line