Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion lists
On 18 September 2011 15:41, Yuri DElia <wavexx@xxxxxxxxxxxx> wrote:
> Bart Schaefer <schaefer <at> brasslantern.com> writes:
>
>> If someone builds up a useful set of these based on this example, please
>> post back to the list.
>
> Just for posterity, this is what I've using since a couple of days:
>
> ##################
> # completition list colorization (emacs style)
> highlight-comp()
> {
> reply=()
> [ -n "$PREFIX" -a ! -d "$PREFIX" ] && reply+=( "=(#b)${PREFIX:q:t}(?)*==1" )
> reply+=( "=(#b)(?)*==1" )
> }
>
> zstyle -e ':completion:*' list-colors highlight-comp
> ##################
>
> It seems to work fine for most cases. This particular code also seems to avoid
> the reset bug as mentioned before (although this wasn't intended).
>
> Is also works for in-word completions, like this:
>
> % ls ///list<TAB>
> etc/ lib/ usr/
>
> but it's also pure chance, since PREFIX in this case seems to be "///list" which
> doesn't pass the "! -d" test (which is done for simple directories). I tried to
> write better code to handle this case, but "$compstate" doesn't seem to put
> anything meaningful (I was expecting insert_positions to be set to something!).
>
> Also, I could avoid the test entirely if I could set a different function when
> completing arguments instead of files. How can I do this?
[...]
> zstyle -e ':completion:*' list-colors highlight-comp
Here you can use something like ":completion:*:files:" instead, i
don't know off hand what the exact value you want is, bindkey some key
to _complete_help and check. Or maybe you want to make it match
against _files rather than the specific tag.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author