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

Re: Supporting %F{...} and %K{...} in Zsh 4.x



On Sun, Dec 17, 2023 at 9:51 PM Grant Taylor <gtaylor@xxxxxxxxxxxxxxxxxx> wrote:
>
> I'll have to test a lot more things to see if everything else is compatible.

I suppose you would want to do that in any case.

> I really prefer using the color names with %F{...} and %K{...} and
> dislike using the terminal control codes as they are annoying to work
> with an maintain.
>
> I guess I could set the color codes in variables and use the variables.

Right, you need to figure out how to write a functional and
maintainable config for zsh 4.2.5, which lacks many niceties
introduced in later versions.

> On 12/17/23 14:02, Roman Perepelitsa wrote:
> > Don't export PROMPT or any other internal zsh parameters.
>
> Please elaborate on this, particularly the down side of doing this.

Exported parameters become a part of the process' environment, which
gets inherited by all child processes. You don't want internal zsh
parameters to be inherited by child processes. In the best case it'll
do nothing, in the worst case it'll break things. To experience the
latter, export PS1 and run `bash --norc`. Notice the broken prompt.

On Sun, Dec 17, 2023 at 10:33 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Why not just something like:
>
> if [[ "${(%):-"%F{red}%f"}" = *red* ]]
> then PROMPT=$'This is an %{\e[31m%}old%{\e[39m%} shell %# '
> else PROMPT='This is a %F{red}new%f shell %# '
> fi

To clarify my earlier point: if both branches work and produce
identical prompt, you can keep just one of them. It's less code to
test and maintain. Branching is necessary only when neither branch
works in all situations or when they have functionally distinct
effects.

Roman.




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