zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: linuxtechguy@gmail.com
Cc: devs <zsh-workers@zsh.org>
Subject: Re: What appears to be inconsistent results from ${(%):-%F{${subscript}}
Date: Mon, 4 Mar 2024 14:28:50 -0800	[thread overview]
Message-ID: <CAH+w=7b+90aEoxLxrC3Nw0mZ2CcEPcrP88E6y=Pm6E0wHty_Og@mail.gmail.com> (raw)
In-Reply-To: <CA+rB6GLO6B8kx95tPTdFzhwhE+yYk4o2AY64TRnj2FgbeLeibQ@mail.gmail.com>

In addition to what Mikael already said ...

On Mon, Mar 4, 2024 at 6:56 AM Jim <linux.tech.guy@gmail.com> wrote:
>
> First, '${(%):-%F{${subscript}}' has unbalanced curly brackets({}), but still works.

Because of the "}" effect Mikael described, the prompt expansion here
will be for e.g. "%F{grey" with end-of string instead of closing
brace.  That happens to work.

>  colorconversion="${(%):-%F{${subscript}}"

You need another set of quotes here, e.g.,

   colorconversion="${(%):-"%F{${subscript}}"}"

Double-quotes can be nested when they are inside a nested parameter expansion.

> 1)  the color names grey and gray do not output black but output the default

For the Nth time, prompt expansion does not correspond to the names
instantiated by the "colors" function.  The "colors" names are for
generating direct output to the terminal, not for populating prompt
strings.

> using decimal numbers(0-255)
>     0 - 15  uses 30-27 and 90-97(bright) instead of using the colors defined
>    by the terminal
> Hex codes appear to work as expected.

     [...] by a sequence in braces following
     the %F, for example %F{red}.  In the latter case the values allowed
     are as described for the fg zle_highlight attribute; *note
     Character Highlighting::.

Numbers 0-7 are interpreted as the names "black","red",...,"white"
Numbers 8-(terminfo maxcolor) are interpreted as the color defined by terminfo
Numbers greater than that are the colors defined by the terminal itself

So the only reliable thing for true-color terminals is to use the hex
codes.  This is not really clearly explained under "Character
Highlighting".


  parent reply	other threads:[~2024-03-04 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 14:56 Jim
2024-03-04 15:07 ` Jim
2024-03-04 18:06 ` Mikael Magnusson
2024-03-04 22:28 ` Bart Schaefer [this message]
2024-03-04 22:50 ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7b+90aEoxLxrC3Nw0mZ2CcEPcrP88E6y=Pm6E0wHty_Og@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=linuxtechguy@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).