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

Re: completion: highlight matching part

On Aug 3,  1:14pm, Tomasz Pala wrote:
} > you have to use "zstyle -e" to set an evaluated style.
} I've found that
} setopt extendedglob
} is also required for this trick to work.

Shouldn't be (if it were, it wouldn't have worked for me, because I
don't have that set).  The complist module sets/restores extendeglob
internally before interpreting the pattern.

I suspect you've got quoting wrong in the reply= assignment when
setting up your zstyle.  There's also an erroneous ":" and extra "}"
in what you say you ended up with.  I think you need:

zstyle -e ':completion:*' list-colors \
    'reply=( "$highlights" ${(s.:.)LS_COLORS} )'

} First thing was to match ($PREFIX) only - this way we colour the right
} (including when someone types * or any glob) letters in case when
} pattern matches more times.

Good catch; I wondered about that after I sent the mail.  I was thinking
backward about which string was going to be matched against, in that I
thought the pattern might have to account for a directory-name prefix,
which is also why I missed this ...

} > The above doesn't work when completing files in subdirectories
} ($PREFIX:t) copes with that. While '/' is not used within some options
} it doesn't break anything.

... so ($PREFIX:t) is definitely the way to go.

} Then I've used (#i) modifier as if $PREFIX matches, there must be some
} matcher-list involved for case insensitiveness.

Well ... not everyone uses matcher-list or case-insensitiveness in it,
but if you do then this is fine.

} > something is forcing e.g. executable files to be colored bold green,
} > directories red, etc., if there is ANY value at all for list-colors or
} These are default GNU ls colors for standard tags - they're supposed to
} be "obtained by setting the style to an empty string", but it doesn't
} work that way...

The complist module installs some defaults if $LS_COLORS is empty.  The
problem is that the form beginning with an equal or a star is supposed
to take precedence over those defaults, but it does not.  Instead (if
I'm reading the code correctly) it takes precedence only over explicit
settings of all the possible $LS_COLORS colorings.

So it works for you because (1) you have a non-empty $LS_COLORS and
(2) you actually included $LS_COLORS in the list-colors style.  It
fails for me because it finds nothing but the =(#b)... in $ZLS_COLORS
and therefore stuffs in its internal defaults.
} At the end I wanted to override * expressions (like *.jpg), but didn't
} succeed. There are problems with disabling and reenabling backreferences:
} ${${(s.:.)LS_COLORS}//#(#b)\*(*)=(*)/'=(#Bbi)($PREFIX:t)(?)*('$match[1]')='$match[2]'=$color[red]=$color[green];$color[bold]=$color[cyan];$color[bold]'}

(This is probably the part where you need extendedglob, for the (#b)
business in the ${...//...} expression.)

You can't use (#B) and (#b) in the same pair of parens like (#Bb).  The
one that comes rightmost will always win.

I'm not entirely clear on why you need to disable the backreferences; why
does is matter?  However, I suspect you think you want this:


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