From 0227e42135f3b6161a0de409b19119bc7f264354 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 1 Sep 2022 20:24:05 +0200 Subject: [PATCH] zsh: change cursor based on mode --- .config/zsh/functions/prompt_tastytea_setup | 1 + .config/zsh/keys.zsh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.config/zsh/functions/prompt_tastytea_setup b/.config/zsh/functions/prompt_tastytea_setup index abbe181..0d9464b 100644 --- a/.config/zsh/functions/prompt_tastytea_setup +++ b/.config/zsh/functions/prompt_tastytea_setup @@ -165,3 +165,4 @@ prompt_tastytea_setup "$@" # Local Variables: # mode: shell-script # End: +# vim: set ft=zsh: diff --git a/.config/zsh/keys.zsh b/.config/zsh/keys.zsh index 4232f6e..e3f1f79 100644 --- a/.config/zsh/keys.zsh +++ b/.config/zsh/keys.zsh @@ -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