diff --git a/sub/zsh/options b/sub/zsh/options index b684319..5933bad 100644 --- a/sub/zsh/options +++ b/sub/zsh/options @@ -14,7 +14,36 @@ WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word PROMPT_EOL_MARK="" # configure key keybindings + +# Activate vim mode. bindkey -v + + +# Change cursor shape for different vi modes. +zle-keymap-select() { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi +} + +zle -N zle-keymap-select + +# Use beam shape cursor on startup. +echo -ne '\e[5 q' + +# Use beam shape cursor for each new prompt. +preexec() { + echo -ne '\e[5 q' +} + + bindkey -M viins 'jk' vi-cmd-mode bindkey ' ' magic-space # do history expansion on space bindkey '^[[3;5~' kill-word # ctrl + Supr