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

Re: [PATCH] prompt: support generic non-visible regions



On Wed, Aug 10, 2022 at 1:56 PM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> readline assumes anything between \001 (start of header) and \002 (start
> of text) is non-visible characters.
>
> In zsh we do this with `%F{color}`, but we could support
> `\001\e[31m\002` as well.

I like this patch but for a different reason. It closes the capability
gap in zsh prompts with and without prompt_percent.

When one disables prompt_percent, they can do all the same things as
before _except_ mark some sequences as zero-width. The loss of this
capability in turn means that one cannot use colors (and many other
things) in prompt without prompt_percent.

With this patch we'll have a nice guarantee that the following two
pieces of code are equivalent:

A:

    emulate -R zsh
    PS1=$whatever

B:

    emulate -R zsh -o no_prompt_percent
    PS1=${(%)whatever}

(Assuming no other prompt parameters are set.)

No real-world use cases come to mind but it just looks simple and
elegant from the user's point of view.

Roman.




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