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 11:43 AM Grant Taylor
<gtaylor@xxxxxxxxxxxxxxxxxx> wrote:
>
> Does anyone have any better ideas on how to support %F / %f and %K / %k
> in Zsh 4.2.5?
That seems like an awful lot of work to go through for something that
doesn't change very often. 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
I'm pretty sure $'...' works properly in 4.2.5, but the closest I can
test with is 4.2.6. In sufficiently old zsh, even the parse of
"${(%):-"%F{red}%f"}" doesn't work.
> export PROMPT=${PROMPT//\%f/%{^[[39m%}}
> export PROMPT=${PROMPT//\%F{black}/%{^[[30m%}}
[...]
What Roman said RE "export".
Also there's no reason to re-export a parameter every time you change
it. Once exported, always exported, unless "typeset +x" is used.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author