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

Re: Completion lists



On Sun, 18 Sep 2011 16:08:29 +0200, Mikael Magnusson wrote:
zstyle -e ':completion:*:files:' list-colors ..

doesn't do what I mean.

As you can see, the tag here is "all-files", not "files". You also
need another * after the last :, I see that I missed that, sorry. I
think you can put either all-files or _files and it might work. Note
that if you set the list-dirs-first style, you'll get other-files and
directories instead of all-files.

Ah, thanks! This:

######
# completition list colorization (emacs style)
highlight-comp()
{
  reply=( "=(#b)${PREFIX:q}(?)*==1" )
}

highlight-comp-files()
{
  reply=()
[ -n "$PREFIX" -a ! -d "$PREFIX" ] && reply+=( "=(#b)${PREFIX:q:t}(?)*==1" )
  reply+=( "=(#b)(?)*==1" )
}

zstyle -e ':completion:*' list-colors highlight-comp
zstyle -e ':completion:*:all-files' list-colors highlight-comp-files
######

...now covers a couple more edge cases where an argument might match some existing files (git completion being one of the main offenders ;)).

One more thing I'd like to cover when completing files.

Is there a way to get the prefix up to the insert position when completing something like:

ls ///list<TAB>
(where the cursor is placed just after the first /)

Looking at the documentation, $compstate should help, but inside the callback function PREFIX is still set to "///list" and $compstate[insert_positions] is empty.



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