zsh: fix cursor shapes in vi-mode

This commit is contained in:
Fernando Schauenburg 2021-08-16 12:26:48 +02:00
parent b4c5c87c9a
commit 92b23adb98

View file

@ -5,18 +5,19 @@ bindkey -v
export KEYTIMEOUT=1 export KEYTIMEOUT=1
set_cursor_shape() { set_cursor_shape() {
if [ -n ITERM_SESSION_ID ]; then local block='\e[1 q' # blinking block
local block='\e]1337;CursorShape=0\a' local underline='\e[3 q' # blinking underline, 4 for steady
local bar='\e]1337;CursorShape=1\a' local bar='\e[5 q' # blinkind bar, 6 for steady
local underline='\e]1337;CursorShape=2\a' if [[ -n $ITERM_SESSION_ID ]] {
else block='\e]1337;CursorShape=0\a'
local block='\e[1 q' beam='\e[3 q' underline='\e[5 q' bar='\e]1337;CursorShape=1\a'
fi underline='\e]1337;CursorShape=2\a'
}
case "$1" in case "$1" in
block) echo -ne "$block" ;; block) echo -n $block ;;
bar) echo -ne "$bar" ;; bar) echo -n $bar ;;
underline) echo -ne "$underline" ;; underline) echo -n $underline ;;
esac esac
} }
@ -30,6 +31,6 @@ zle-keymap-select() {
zle -N zle-keymap-select zle -N zle-keymap-select
# Start new prompts with bar shaped cursor. # Start new prompts with bar shaped cursor.
zle-line-init() { set_cursor_shape bar; } zle-line-init() { set_cursor_shape bar }
zle -N zle-line-init zle -N zle-line-init