zsh vi mode status line

Viewed 11181

Is there a way in zsh or bash to have a status line? e.g. in VI it will let you know that you are in insert mode with -- INSERT --

Is there an eqivalent for the command line?

2 Answers

Exactly, I can understand your concern and if you don't mind using a plugin, I think the below one can help you show the vi mode status perfectly, also the additional bonus of better experience on vi mode and so on.

zsh-vi-mode: A better and friendly vi(vim) mode plugin for ZSH.
https://github.com/jeffreytse/zsh-vi-mode

This plugin has provided a ZVM_MODE variable for you to retrieve current vi mode and better show the indicator.

And currently the below modes are supported:

ZVM_MODE_NORMAL
ZVM_MODE_INSERT
ZVM_MODE_VISUAL
ZVM_MODE_VISUAL_LINE

For updating the vi mode indicator, we should add our commands to zvm_after_select_vi_mode_commands. For example:

After you install this plugin

# The plugin will auto execute this `zvm_after_select_vi_mode` function
function zvm_after_select_vi_mode() {
  case $ZVM_MODE in
    $ZVM_MODE_NORMAL)
      # Something you want to do...
      ;;
    $ZVM_MODE_INSERT)
      # Something you want to do...
      ;;
    $ZVM_MODE_VISUAL)
      # Something you want to do...
      ;;
    $ZVM_MODE_VISUAL_LINE)
      # Something you want to do...
      ;;
  esac
}

Here is an example:

demo

Related