diff options
author | ene <ene@sils.li> | 2023-02-15 18:23:49 +0100 |
---|---|---|
committer | ene <ene@sils.li> | 2023-02-15 18:24:30 +0100 |
commit | 944edc4385e8aad92e18fabc7ff0ba24f42ea9b7 (patch) | |
tree | c3cb4bee8008f79f2fb066a40921a78be2e68a59 /home-manager/zsh/config/custom_cursor.sh | |
parent | Feat(home-manager): Add yambar (diff) | |
download | nixos-config-944edc4385e8aad92e18fabc7ff0ba24f42ea9b7.tar.gz nixos-config-944edc4385e8aad92e18fabc7ff0ba24f42ea9b7.zip |
Feat(home-manager): Add zsh
Diffstat (limited to 'home-manager/zsh/config/custom_cursor.sh')
-rw-r--r-- | home-manager/zsh/config/custom_cursor.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/home-manager/zsh/config/custom_cursor.sh b/home-manager/zsh/config/custom_cursor.sh new file mode 100644 index 00000000..9a6da012 --- /dev/null +++ b/home-manager/zsh/config/custom_cursor.sh @@ -0,0 +1,40 @@ +# Change cursor shape for different vi modes. +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 + +# ci", ci', ci`, di", etc +autoload -U select-quoted +zle -N select-quoted +for m in visual viopp; do + for c in {a,i}{\',\",\`}; do + bindkey -M $m $c select-quoted + done +done + +# ci{, ci(, ci<, di{, etc +autoload -U select-bracketed +zle -N select-bracketed +for m in visual viopp; do + for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do + bindkey -M $m $c select-bracketed + done +done + +zle-line-init() { + zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) + echo -ne "\e[5 q" +} +zle -N zle-line-init + +echo -ne '\e[5 q' # Use beam shape cursor on startup. +precmd() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. |