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

Re: Turning display attributes on / off in prompt strings



On Sat, Dec 17, 2022 at 1:47 AM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Bart Schaefer wrote:
> > the present prompt code would still emit the
> > then-unnecessary sequences to restore the other attributes.
>
> It's probably not worth replacing the escape sequence without also
> allowing it to avoid that because the original problem would only be
> partially solved.

Hm, I was thinking of it more as a new problem of optimization (we go
to some lengths in other places to send the shortest possible control
sequences).  In what way would the original problem not be solved?  An
attribute might be turned back on after having been turned off?

> We do already have an interface in the form of zle -T transformation func
> Transformation is currently only "tc" for termcap but something for end
> bold* or general attribute changing could be added. Prompt handling is in
> the main part of zsh rather than zle but the zle module could define a
> callback.

Hm, that's a bit more heavyweight than I was thinking, but would be
the most flexible.

I presume you mean to move the transformation to the main shell and
have zle call it?  Loading zle in non-interactive context would be
less desirable?

> * \e[22m selects normal, disabling also faint so naming indicating end
> of bold would be a poor choice.

That's true, outside of prompt context (which doesn't currently have a
way to express "faint" without using raw sequences).  But all the
other attributes are additive whereas faint/normal/bold are mutually
exclusive even at the terminal level, we're not going to be able to
make a general solution for (faint on)(bold on)(bold off) that ends in
(faint on) state.




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