From dfd12c1f8c2d884666fc758d531ff99f1c079902 Mon Sep 17 00:00:00 2001 From: Jakob Kofod Beyer Date: Thu, 1 Mar 2018 16:24:36 +0100 Subject: [PATCH] Add different cursors for normal and insert mode --- plugins/vi-mode/vi-mode.plugin.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 82a2f3040..742c84781 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -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