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

Re: coloring a substitution




On 2022-11-08 13:10, Roman Perepelitsa wrote:

- `print` is equivalent to `print -r --` here
Right!  It's one of those things that's easy to overlook until some weird name bites you.

   recent[$aa]=${recent[$aa]//(#i)$filter/$'\e['$color';1m'$filter$'\e[0m'}

Therewego, > $'\e[' < replaces  > \x1b\[ <.

Thanks Roman.

BTW as it stands now my filtering issue on the other thread:

For globbing for files on the disk: ($zsh_case = '(#i)'):

    [ "$wild_msg" = 'WILD' ] \
                && eval "wholedisk=( $zsh_case/**/*$1*(/N) )" \
                || eval "wholedisk=( $zsh_case/**/$1(/N) )"

For string searches in the directory stack:

for (( aa = 1; aa <= $#cc; aa++ )); do

# These are full names, $1 may be only a partial match if we are WILD.
dirname=${cc[$aa]:t}

if [[ "$scope_msg" = 'BROAD'                  && $dirname = (#i)*$1* ]] \
|| [[ "$scope_msg" = 'Case INsensitive TAME' && $dirname:u = $1:u ]] \
|| [[ "$scope_msg" = 'Case Sensitive WILD'      && $dirname =~ $1 ]] \
|| [[ "$scope_msg" = 'EXACT'                  && $dirname = $1 ]]; then ; # Do nothing, we have a match.
else cc[$aa]=    # Kill the line, it does not match.
fi
done

... any further improvements?

Roman.





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