Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: coloring substitution seems to eat next line.
On 2022-11-10 13:51, Roman Perepelitsa wrote:
If you look back, you can find in my answers a way to:
1. Remove all elements of an array that don't match a pattern. It has this form:
array=(${(M)array:#pattern})
2. Perform a replacement in all elements of an array. Like this:
array=(${array//pattern/substitute})
Fabulous:
for filter in "$@"; do
cc=( ${(M)cc:#*$~zsh_case${filter}*} )
cc=(
${cc//(#b)($~zsh_case${filter})/$'\e['$color;1m${match[1]}$'\e[0m'} )
done
... no need for a a loop processing each line one at a time. Once the
non-matching lines are removed, the whole array can be colorized in one
gulp. I knew there'd be an elegant way.
You can save a tremendous amount of time by reading the official guide
and the reference.
IF you know what you are looking for! I can't look for '(M)' before I
know the thing exists to be looked for.
Set aside an evening or two and read them from
start to end.
This mortal would need to devote a year to it. I have tried but one
needs to understand the jargon before it's even intelligible. But yes,
it needs to be learned from the outside in. You experts don't realize
how steep the learning curve is. Oh, for a glossary!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author