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

Re: coloring a substitution



On Wed, Nov 9, 2022 at 12:50 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> 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) )"

Try this instead:

  if [[ $wild_msg = WILD ]]; then
   wholedisk=( $~zsh_case/**/*$~1*(/N) )
  else
   wholedisk=( $~zsh_case/**/$~1(/N) )
  fi

These cases would more traditionally be called "partial match" and "full match".

> 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

Try this instead:

  if [[ $scope_msg = 'BROAD'                  && $dirname = (#i)*$~1* ]] ||
     [[ $scope_msg = 'Case INsensitive TAME' && $dirname = (#i)$~1 ]] ||
     [[ $scope_msg = 'Case Sensitive WILD'      && $dirname = *$~1* ]] ||
     [[ $scope_msg = 'EXACT'                  && $dirname = $~1 ]]; then

If this works, consider using more traditional names for these cases:

- case-insensitive partial
- case-insensitive full
- case-sensitive partial
- case-sensitive full

You can also shorten "case-insensitive" to "icase" and
"case-sensitive" to nothing. This is a commonly used naming
convention.

You can also use $~zsh_case in here.


Roman.




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