Skip to content

Instantly share code, notes, and snippets.

@chrismccord
Created September 27, 2013 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismccord/6723644 to your computer and use it in GitHub Desktop.
Save chrismccord/6723644 to your computer and use it in GitHub Desktop.
zsh vi mode status
vim_ins_mode="[INS]"
vim_cmd_mode="[CMD]"
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
RPROMPT='${vim_mode}'
RPROMPT2='${vim_mode}'
setopt transient_rprompt # don't show command modes on previously accepted lines
@jondkinney
Copy link

This was all I needed

bindkey -v

function zle-keymap-select {
  zle reset-prompt
}
zle -N zle-keymap-select

And that added a nice red << to the front of my prompt when I am in command mode.

I also prefer to put my ruby version and gemset in my RPROMPT so I'm happy with this more minimal solution.

Thanks!

Normal insert mode - http://cl.ly/RdoQ

Command mode - http://cl.ly/Rd7E

@jeffreytse
Copy link

Hey! Just created a new zsh-vi-mode plugin, don't you want to have a try?

It's a totally very fresh release and maybe you'll like it, faster switching speed between normal mode and insert mode, and faster key response, bring you to real life, anyway welcome to be the early adopter, please upvote by commenting this post, many thanks for you (vimers).

https://github.com/jeffreytse/zsh-vi-mode

Features

  • Cursor movement (Navigation).
  • Insert & Replace (Insert mode).
  • Text Objects.
  • Searching text.
  • Undo, Redo, Cut, Copy, Paste, and Delete.
  • Surrounds (Add, Replace, Delete, and Move Around).
  • Switch keywords (Increase/Decrease Number, Boolean, etc. In progress).
  • ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment