On 5/11/24 07:37, Roman Perepelitsa wrote:
On Sat, May 11, 2024 at 4:27 PM Mikael Magnusson <mikachu@gmail.com> wrote:
On Sat, May 11, 2024 at 2:54 AM Kannan Varadhan <kvaradhan3@gmail.com> wrote:

~⦒printf '%s.%s.%s\n' "${(%):-%F{blue}%B}" "test" "${(%):-%b}${(%):-%f}"
%B}.test.
You probably have a badly made / cargo culted precmd() function
active.

I am sorry, I did not follow this.

That output is actually expected. The right curly must be escaped.

    printf '%s.%s.%s\n' "${(%):-%F{blue\}%B}" "test" "${(%):-%b}${(%):-%f}"

Yes, this works,  

Is this something that I missed in the documentation? 

Many useful, useable variants, thank you for these.

However, it's easier to use `print -P`:

    print -P '%F{blue}%Btest%b%f'

Or, when printing $var:

    print -rP '%F{blue}%B'${var//\%/%%}'%b%f'

Alternatively:

    print -Pn '%F{blue}%B'
    print -rn -- $var
    print -P '%b%f'

Another alternative:

    print -r -- ${(%):-'%F{blue}%B'${var//\%/%%}'%b%f'}


Kannan