diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md new file mode 100644 index 00000000..473ca1b4 --- /dev/null +++ b/plugins/vi-mode/README.md @@ -0,0 +1,3 @@ +# Vi-mode + +Vi-mode plugin. diff --git a/plugins/vi-mode/plugin.zsh b/plugins/vi-mode/plugin.zsh new file mode 100644 index 00000000..2520745a --- /dev/null +++ b/plugins/vi-mode/plugin.zsh @@ -0,0 +1,18 @@ + +# For some reason this line doesn't work inside a function, otherwise +# it should be located in the _setup function. +zle -N zle-keymap-select geometry_prompt_vi-mode_render +geometry_prompt_vi-mode_setup() {} + +geometry_prompt_vi-mode_check() {} + +geometry_prompt_vi-mode_render() { + # Removes previously state + RPROMPT=${${RPROMPT/\[INSERT\] /}/\[NORMAL\] /} + # swaps main/INSERT, vicmd/NORMAL + local KEY=${${KEYMAP/main/INSERT}/vicmd/NORMAL} + # Formats RPROMPT with mode + rest of prompt + RPROMPT="[$KEY] $RPROMPT" + # Resets prompt + zle && zle reset-prompt +}