Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Add $ZLE_STATE in zle widgets



Peter Stephenson wrote:
> On Wed, 11 Aug 2010 14:54:42 +0200
> Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
>> Peter Stephenson wrote:
>> > Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
>> >> > I'm pretty happy with my current setup anyway. It would be cool
>> >> > to have a way to add a "V" mode to my prompt when `vared' is
>> >> > active. That could probably be done with {pre,post}-vared hook
>> >> > widgets. I didn't look into that yet, though.  (Actually, since
>> >> > I wrote this mail while being on a train, I did look at this by
>> >> > now. This is not as trivial as I had hoped, since zle cannot be
>> >> > run recursively. Oh well, I'm rarely using `vared' anyway.)
>> >> 
>> >> Should be trivial to add this to ZLE_STATE internally.
>> >
>> > Turns out you can already test [[ $CONTEXT = vared ]].
>> 
>> Yes. But for my problem (signal that a vared is running in the shells
>> *main* prompt) that doesn't help, because there's no widget called
>> at the right time.
>
> The following seemed to work, am I missing what you're doing?
>
> setopt promptsubst
> PS1='$MYCONTEXT %# '
> zle-line-init() {
>   typeset -g MYCONTEXT=$CONTEXT
>   zle reset-prompt
> }
> zle -N zle-line-init
>
> Now "vared -p $PS1" shows up "vared", otherwise I get "start" (or, in
> principle, "cont").

But that would put the information in vared's PS1 and not in the one of
the shell that called vared, wouldn't it? If I could do that, I'd know
if vared is active even without using its `-p' option.

I could live with doing this, though:
    vared() { builtin vared -p 'vared %% ' "$@" }

Regards, Frank



Messages sorted by: Reverse Date, Date, Thread, Author