From: Marlon Richert <marlon.richert@gmail.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Bart Schaefer <schaefer@brasslantern.com>,
Roman Perepelitsa <roman.perepelitsa@gmail.com>,
Zsh Users <zsh-users@zsh.org>
Subject: Re: Why are prompt expansions of %v sequences quoted in bindkey style?
Date: Thu, 25 Jan 2024 10:42:57 +0200 [thread overview]
Message-ID: <CEA434FC-FC48-40D0-9163-816C832CF5C2@gmail.com> (raw)
In-Reply-To: <CAHYJk3TrCjXJXO12UJUepp78EKrsBfTF+SHYy9AiQwhiysGqgQ@mail.gmail.com>
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@gmail.com> wrote:
>
> On 1/24/24, Marlon Richert <marlon.richert@gmail.com> wrote:
>>> On Wed, Jan 24, 2024 at 10:53 AM Mikael Magnusson <mikachu@gmail.com>
>>> 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
next prev parent reply other threads:[~2024-01-25 8:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 11:03 Marlon Richert
2024-01-23 13:05 ` Roman Perepelitsa
2024-01-23 18:43 ` Marlon Richert
2024-01-23 18:55 ` Roman Perepelitsa
2024-01-23 19:15 ` Bart Schaefer
2024-01-23 20:21 ` Mikael Magnusson
2024-01-24 5:45 ` Marlon Richert
2024-01-24 8:53 ` Mikael Magnusson
2024-01-24 13:37 ` Marlon Richert
2024-01-24 19:35 ` Mikael Magnusson
2024-01-25 8:42 ` Marlon Richert [this message]
2024-01-25 9:20 ` Lawrence Velázquez
2024-01-25 16:16 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CEA434FC-FC48-40D0-9163-816C832CF5C2@gmail.com \
--to=marlon.richert@gmail.com \
--cc=mikachu@gmail.com \
--cc=roman.perepelitsa@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).