diff options
| author | Jean-Pierre Appel <jeanpierre.appel01@gmail.com> | 2023-02-21 01:08:55 -0500 |
|---|---|---|
| committer | Jean-Pierre Appel <jeanpierre.appel01@gmail.com> | 2023-02-21 01:08:55 -0500 |
| commit | ff7c336bd517594e1bab1c27cd504b5a6f62e547 (patch) | |
| tree | ba85ee4e50133b903433f347599fd625a557ffba /zsh/zshvimodes | |
| parent | 11b04ad1e5ef81d42c4384af94d7ba4161f0c160 (diff) | |
added zsh config
Diffstat (limited to 'zsh/zshvimodes')
| -rw-r--r-- | zsh/zshvimodes | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/zsh/zshvimodes b/zsh/zshvimodes new file mode 100644 index 0000000..ab60972 --- /dev/null +++ b/zsh/zshvimodes @@ -0,0 +1,23 @@ +#vim_ins_mode="%{$fg[cyan]%}[INS]%{$reset_color%}" +vim_ins_mode="" +vim_cmd_mode="%{$fg[green]%}[CMD]%{$reset_color%}" +vim_mode=$vim_ins_mode + +function zle-keymap-select { + vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}" + zle reset-prompt +} +zle -N zle-keymap-select + +function zle-line-finish { + vim_mode=$vim_ins_mode +} +zle -N zle-line-finish + +# Fix a bug when you C-c in CMD mode and you'd be prompted with CMD mode indicator, while in fact you would be in INS mode +# Fixed by catching SIGINT (C-c), set vim_mode to INS and then repropagate the SIGINT, so if anything else depends on it, we will not break it +# Thanks Ron! (see comments) +function TRAPINT() { + vim_mode=$vim_ins_mode + return $(( 128 + $1 )) +} |
