From b2eb4c81f735ed47fd466ac73c2402a35c883d09 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Wed, 9 Sep 2020 09:43:52 -0400 Subject: feat(gs/zshrc): Change cursor shape based on mode Use a block cursor in normal mode, and a beam cursor in insert mode. Change-Id: I1cf5eebeaadf41cd006b324de62eb7f6804e149a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1965 Reviewed-by: glittershark Tested-by: BuildkiteCI --- users/glittershark/system/home/modules/zshrc | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'users/glittershark') diff --git a/users/glittershark/system/home/modules/zshrc b/users/glittershark/system/home/modules/zshrc index cca822c4ce..a12173d684 100644 --- a/users/glittershark/system/home/modules/zshrc +++ b/users/glittershark/system/home/modules/zshrc @@ -236,9 +236,6 @@ function dbp () { # }}} -# Vagrant {{{ -# }}} - # Twitter! {{{ @@ -264,9 +261,6 @@ gnc() { } # }}} -# Systemd aliases {{{ -# }}} - # Misc aliases {{{ function fw() { # fix white @@ -303,4 +297,31 @@ export GREP_OPTIONS= # glittershark/firefox # }}} +# Change cursor shape on insert/normal mode {{{ +# (https://unix.stackexchange.com/q/433273/64261) + +KEYTIMEOUT=5 + +_fix_cursor() { + echo -ne '\e[5 q' +} + +precmd_functions+=(_fix_cursor) + +function 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 + +# }}} + [ -f ./.localrc ] && source ./.localrc -- cgit 1.4.1