diff --git a/terminal/.config/zsh/.zshrc b/terminal/.config/zsh/.zshrc index 30a0a4c..f4156a8 100644 --- a/terminal/.config/zsh/.zshrc +++ b/terminal/.config/zsh/.zshrc @@ -151,6 +151,26 @@ bindkey "^[." insert-last-word bindkey -v # remove the delay for switching modes export KEYTIMEOUT=1 +# Change cursor shape for different vi modes. +function zle-keymap-select { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[2 q' + + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[6 q' + fi +} +zle -N zle-keymap-select +# Use beam shape cursor on startup. +_fix_cursor() { + echo -ne '\e[6 q' +} +precmd_functions+=(_fix_cursor) + # space puts a space, even in cmd mode bindkey -a ' ' magic-space # always allow backspace/delete to remove letters