about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-09-09T13·43-0400
committerglittershark <grfn@gws.fyi>2020-09-09T14·25+0000
commitb2eb4c81f735ed47fd466ac73c2402a35c883d09 (patch)
tree613151fd5bd7f6e9a845b6f82d7b2bd153964b2c
parentb8b2a499e1afe5cd138b98d1cc64d400c8b28d32 (diff)
feat(gs/zshrc): Change cursor shape based on mode r/1775
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
-rw-r--r--users/glittershark/system/home/modules/zshrc33
1 files changed, 27 insertions, 6 deletions
diff --git a/users/glittershark/system/home/modules/zshrc b/users/glittershark/system/home/modules/zshrc
index cca822c4ce3e..a12173d6842d 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