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

Re: Completing possible elements of a comma-separated list



Malte Starostik wrote:
> 
> I'm trying to write a completion for slptool. One of its commands is
>     slptool findattrs <service> [attr ids]

> Now I'd like to continue completion with the same list of possible matches,
> completing any id in the comma separated list independently of each other
> against the list of available ids.

Easiest way is probably to use:
  _values -s , 'attribute id' $(slptool findattrs ...)

Otherwise, you can use:

local -a suf
compset -P '*,'
compset -S ',*' || suf=( -S , )
compadd ... "$suf[@]" ...

That'll make it ignore anything before the cursor up the last comma
(and the same in reverse for after the cursor).

> Also, would be nice if
>     slptool findattrs example.acme u,p<TAB>
> could complete to
>     slptool findattrs example.acme username,password,
> as well.

That's harder. _sep_parts or _multi_parts might help you. Otherwise, you
need to start using compadd -O and it gets complicated.

Oliver



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