zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Grant Taylor <gtaylor@tnetconsulting.net>
Cc: zsh-users@zsh.org
Subject: Re: Help fix Zsh shell command prompt error or stranee
Date: Tue, 22 Aug 2023 08:26:51 +0200	[thread overview]
Message-ID: <CAN=4vMqzvMRijxp_qWzi-tr2+5ncqWvP-dbJKtbf_Z7YKvGbZg@mail.gmail.com> (raw)
In-Reply-To: <b2adb205-073e-c72f-f4fd-3925e8ab44eb@tnetconsulting.net>

On Tue, Aug 22, 2023 at 1:37 AM Grant Taylor <gtaylor@tnetconsulting.net> wrote:
>
> On 8/20/23 1:30 AM, Roman Perepelitsa wrote:
> > In the vast majority of cases one can replace %{...%} with a
> > first-class %-sequence.
>
> I question the "vast" quantifier.

I'm intrigued. When is %{...%} necessary?

These are the use-cases I know of, and I would venture a guess that
they apply to a small minority of users:

1. To work around bugs in the terminal. For example, if the terminal
    displays "X" as a wide character, you would need to use "%2{X%}"
    instead of the plain "X".
2. To embed special markers at the start and the end of the prompt
    that are recognized by the terminal.
3. To use styling that isn't available through %-escapes. For example,
    italic, or dim.

Are there any other use cases for %{...%}?

Note that it's not necessary (and not a good idea anyway) to embed
special terminal commands into prompt. Things like setting the
terminal title, notifying the terminal about the current working
directory, etc. These are better done by writing to the TTY in the
corresponding hooks (precmd, chpwd, etc.). This is different from
prompt markers that I mentioned above, which must be embedded into the
prompt.


Roman.


  reply	other threads:[~2023-08-22  6:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-19  0:35 Budi
2023-08-19  2:01 ` Grant Taylor
2023-08-20  6:30   ` Roman Perepelitsa
2023-08-20 10:50     ` Budi
2023-08-20 17:11       ` Bart Schaefer
2023-08-20 15:54     ` Grant Taylor
2023-08-22  6:26       ` Roman Perepelitsa [this message]
2023-08-23  4:27         ` Grant Taylor
2023-08-19 16:09 ` Bart Schaefer

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='CAN=4vMqzvMRijxp_qWzi-tr2+5ncqWvP-dbJKtbf_Z7YKvGbZg@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=gtaylor@tnetconsulting.net \
    --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).