From: Kannan Varadhan <kvaradhan3@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: colorizing printfs
Date: Fri, 10 May 2024 17:52:07 -0700 [thread overview]
Message-ID: <8d1d947e-75af-4a9a-b726-dabe9858b2b0@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]
My version:
~⦒zsh --version ▮▮▮▮▮▮▯▯▯▯ 17:26:13
zsh 5.9 (x86_64-pc-linux-gnu)
I am trying out variations suggested here:
https://unix.stackexchange.com/questions/408867/how-to-colorize-some-of-the-output-of-a-shell-script
and am confused.
One of the last (I expect ideal) suggestions is:
% text=xyz
% |printf '%s\n' "${(%):-%F{green}}$text${(%):-%f}"|
|
|
|When I try it:|
|~⦒printf '%s\n' "${(%):-%F{blue}}test${(%):-%f}" ▮▮▮▮▮▯▯▯▯▯ 17:33:45
}test|
|I have a trailing `}' which I think I should not see.|
|If I split this up,|
|~⦒printf '%s.%s.%s\n' "${(%):-%F{blue}}" "test"
"${(%):-%f}" ▮▮▮▮▮▯▯▯▯▯ 17:35:41
}.test.
~⦒printf '%s.%s.%s\n' "${(%):-%F{blue}}${(%):-%B}" "test"
"${(%):-%b}${(%):-%f}"
}*.test.*|
||
|same result. The extra parenthesis, but the %B/%b print codes worked
as expected.
|
|If my reading of the zsh man pages is correct, this one should be
identical to the last one above,
|
|~⦒printf '%s.%s.%s\n' "${(%):-%F{blue}%B}" "test"
"${(%):-%b}${(%):-%f}"
%B}.test.
|
|Instead I get the above `%B}' in the output.|
|
|
|What would I be missing?|
|
|
|Curious,|
|
|
|Kannan
|
[-- Attachment #2: Type: text/html, Size: 233981 bytes --]
next reply other threads:[~2024-05-11 0:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 0:52 Kannan Varadhan [this message]
2024-05-11 14:26 ` Mikael Magnusson
2024-05-11 14:37 ` Roman Perepelitsa
2024-05-12 0:19 ` Kannan Varadhan
2024-05-12 6:44 ` Roman Perepelitsa
2024-05-13 20:53 ` Rick Bowen
2024-05-14 6:48 ` Stephane Chazelas
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=8d1d947e-75af-4a9a-b726-dabe9858b2b0@gmail.com \
--to=kvaradhan3@gmail.com \
--cc=zsh-users@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).