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

Re: zsh completion with _files



Cornelius Kölbel wrote:
> 
> I used tests for the previous and the pre-previous word like
> $words[$#words-1 or 2] .

That might not be want you want if the cursor is in the middle of the
line rather than at the end. You might want $words[CURRENT] or
$words[CURRENT-1], etc.

> I realized that it might work this way:
> 
>         local curr=$words[$#words]
> 
>         case $curr in
>         @*)
>                 _files
>         ;;
>         esac

> But then it is looking for files starting with @.

You need to move the @ character from the PREFIX to the IPREFIX
variable. There's a shortcut for this using the compset command:
  if compset -P '@'; then
    _files
  else
    ...

Oliver



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