zsh-users
 help / color / mirror / code / Atom feed
* [Fwd: Re: vi mode]
@ 2006-11-17 16:03 William Scott
  0 siblings, 0 replies; only message in thread
From: William Scott @ 2006-11-17 16:03 UTC (permalink / raw)
  To: zsh-users

For the collective memory:

On 11/17/06, William Scott <wgscott@chemistry.ucsc.edu> wrote:
>  So what did Bart actually suggest?  I'd like to do this too.  I switched
> to vi mode a couple of months ago and in general like it better, but
> found that my brain had been hard-wired to do vi for editing and
> emacs-bindings for shell interaction, so it is still slightly awkward.
> What would be kind of cool is if the color of the prompt could change or
> the title bar could change dynamically.
>

Getting the titlebar to change dynamically is a piece of cake.  The
color of the prompt isn't too hard, either.  My desire for a text
indicator that is somewhere other than the prompt proved to be nearly
impossible, however.

Bart suggested this, which would make the current mode appear on the
far right of the screen as a right side prompt.

   function zle-line-init zle-keymap-select {
     RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
     RPS2=$RPS1
     RPS3=$RPS1
     RPS4=$RPS1
     zle reset-prompt
   }
   zle -N zle-line-init

On the other hand, if you'd like to just have your normal prompt
change colors, the following should work, assuming that the first
thing in your prompt string definition is a color escape insulated
between '%{' and '%}'.  For instance, mine is
PS1=$'%{\e[34;1m%}%20>..>%1~%>>>%{\e[0m%}'

Try something like this:
function zle-keymap-select {
PS1=${${1/vicmd/$'%{\e[31;1m%}'}/(viins|main)/$'%{\e[34;1m%}'}${PS1#*%\}}
zle reset-prompt
}

where 31;1m is the color code that you want for normal mode (that's
bright red) and 34;1m is the color code for insert mode (bright blue).

If you have any more questions, you should probably direct them
towards the zsh-users list, so other people can benefit from the
answers.

~Matt


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-11-17 16:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-17 16:03 [Fwd: Re: vi mode] William Scott

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).