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 <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2020-09-09 09:43:52 -04:00 committed by glittershark
parent b8b2a499e1
commit b2eb4c81f7

View file

@ -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