From 56f97684a82a54962ae35848e8edc3b4edfb8aae Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 4 Oct 2023 21:38:32 +0200 Subject: [PATCH] zsh: minor renames/reorder --- config/zsh/vi-mode.zsh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/config/zsh/vi-mode.zsh b/config/zsh/vi-mode.zsh index 243802f..1539122 100644 --- a/config/zsh/vi-mode.zsh +++ b/config/zsh/vi-mode.zsh @@ -1,7 +1,3 @@ -# Use vi mode for line editing. -bindkey -v -export KEYTIMEOUT=1 - set_cursor_shape() { local block='\e[1 q' # blinking block local underline='\e[3 q' # blinking underline, 4 for steady @@ -19,18 +15,25 @@ set_cursor_shape() { esac } +# Start new prompts with bar shaped cursor. +init_line_editor() { + set_cursor_shape bar +} + # Switch cursor shape depending on editing mode. -zle-keymap-select() { +keymap_did_change() { case $KEYMAP in vicmd) set_cursor_shape block ;; viins|main) set_cursor_shape bar ;; esac } -zle -N zle-keymap-select -# Start new prompts with bar shaped cursor. -zle-line-init() { set_cursor_shape bar } -zle -N zle-line-init +zle -N zle-line-init init_line_editor +zle -N zle-keymap-select keymap_did_change + +# Use vi mode for line editing. +bindkey -v +export KEYTIMEOUT=1 # Search through history in insert mode. bindkey -M viins '^j' history-beginning-search-forward