Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: coloring substitution seems to eat next line.



On Sun, Nov 13, 2022 at 4:10 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Roman:
>
>              cc=( ${(M)cc:#*$~zsh_case${filter}*} )
>
> I've been applying that in some other functions but I need a variation
> that will erase non-matching lines but leave them as blanks so that
> array indexes do not change.

This should do it:

  cc=( "${(@)cc/#%$~zsh_case^(*$filter*)}" )

This uses ${name/pattern/repl} with the pattern starting with %# to
signify full match. Within the pattern ^ is negation. Double quotes
with (@) are to retain empty elements. The rest you've already used,
so it should be familiar.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author