1
0
Fork 0

zsh: change cursor based on mode

This commit is contained in:
tastytea 2022-09-01 20:24:05 +02:00
parent e0d1f648f8
commit 0227e42135
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 17 additions and 0 deletions

View File

@ -165,3 +165,4 @@ prompt_tastytea_setup "$@"
# Local Variables:
# mode: shell-script
# End:
# vim: set ft=zsh:

View File

@ -41,8 +41,24 @@ function zle-line-finish () {
echoti smkx
fi
}
# Change cursor based on mode
print -n '\e[6 q'
function zle-keymap-select() {
if [[ "${KEYMAP}" == "viins" || "${KEYMAP}" == "main" ]]; then
print -n '\e[6 q' # beam
else
print -n '\e[2 q' # block
fi
}
function _fixcursor() {
print -n '\e[6 q'
}
add-zsh-hook precmd _fixcursor
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
zle -N history-substring-search-up
zle -N history-substring-search-down