From 483163dbbc56d0d1894fabf437d0252e9cabc8a7 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Mon, 9 Aug 2021 19:21:03 +0200 Subject: [PATCH] zsh: use vi mode with cursor shape matching mode --- files/zshrc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/files/zshrc b/files/zshrc index 284c437..99767ce 100644 --- a/files/zshrc +++ b/files/zshrc @@ -16,3 +16,18 @@ HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/history" HISTSIZE=1000000 SAVEHIST=1000000 +# Use vi mode for line editing. +bindkey -v + +# Use beam cursor on each new prompt +precmd() { echo -ne '\e[5 q'; } + +# Switch cursor shape depending on editing mode. +zle-keymap-select() { + case $KEYMAP in + vicmd) echo -ne '\e[1 q';; # block cursor for command mode + viins|main) echo -ne '\e[5 q';; # beam cursor for insert mode + esac +} +zle -N zle-keymap-select +