Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why are prompt expansions of %v sequences quoted in bindkey style?
This is the first time I’ve seen `typeset -n`. I didn’t know such a feature exists.
Is this documented anywhere? I’m unable to find it in the typeset documentation. I’m not able to find it by searching for “nameref” either.
> On 24. Jan 2024, at 21.35, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On 1/24/24, Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
>>> On Wed, Jan 24, 2024 at 10:53 AM Mikael Magnusson <mikachu@xxxxxxxxx>
>>> wrote:
>>>
>>>
>>> Thinking about this made me realize that namerefs can be quite useful
>>> here, eg
>>> typeset -n .prompt.logicaldescription='psvar[3]'
>>> then you don't have to remember what number you decided to use for
>>> what (I always forget what I picked). And it makes code using them
>>> slightly more self descriptive.
>>>
>>
>> Can you give an example of how you would use this in practice? I'm not sure
>> I understand.
>
> I have a section in my prompt only shows if psvar[9] contains some string:
> {5935|20:34:22|~}% psvar[9]=hello
> {5936|20:34:22|~}(hello)%
>
> but with the nameref i can do this:
> {5937|20:34:47|~}% .prompt.currenttask=hi\ there
> {5938|20:34:47|~}(hi there)%
>
> which is easier (with tabcompletion). It also makes the code that sets
> .prompt.gitbranch a bit clearer.
>
> --
> Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author