Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[Fwd: Re: vi mode]
- X-seq: zsh-users 11002
- From: "William Scott" <wgscott@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: [Fwd: Re: vi mode]
- Date: Fri, 17 Nov 2006 08:03:05 -0800 (PST)
- Importance: Normal
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
For the collective memory:
On 11/17/06, William Scott <wgscott@xxxxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author