Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Turning display attributes on / off in prompt strings
- X-seq: zsh-workers 51232
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Turning display attributes on / off in prompt strings
- Date: Sat, 17 Dec 2022 10:47:48 +0100
- Archived-at: <https://zsh.org/workers/51232>
- In-reply-to: <CAH+w=7aQ+cC26KB5U+0w50XVEp49MnpJrFCT-Eokys7su1azbQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7Yt757b8erwTo5Y1+1fBSQbShV6XCaM8q6wnkGZHmQqeA@mail.gmail.com> <37998-1671237833.378022@KQt2.DuNm.SJtt> <CAH+w=7aQ+cC26KB5U+0w50XVEp49MnpJrFCT-Eokys7su1azbQ@mail.gmail.com>
Bart Schaefer wrote:
> A consideration is that if we simply replaced $"\e[m' with $'\e[24m'
> and so on, the present prompt code would still emit the
> then-unnecessary sequences to restore the other attributes. Is it
> worth the effort to rework that?
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.
> > And if we need a way to
> > override terminal settings, something more generic may be better.
>
> Would populating a writable special hash parameter be a security issue?
I can't think of anything it would open up that isn't already the case.
It can depend on what you regard as untrusted data.
> As you implied, though, the hash key names could be tricky to choose.
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. The existing tc transformation interface doesn't make it easy
to modify only some capabilities, you'd need to reimplement tparm(3) in
shell code. A function provides maximum flexibility but could be slow
and a string would suffice for most uses. A hash seems like a nicer
interface but we can have a transformation function do the hash lookup
and keep that in shell code.
Oliver
* \e[22m selects normal, disabling also faint so naming indicating end
of bold would be a poor choice.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author