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

Re: Match on range



Bek Oberin wrote:

> For the completion of playcd, I want to match any number of a range
> created like this:
>    1-`cd-discid /dev/cdrom | cut -f2 -d' '`
> but I can't get compctl to recognize it as a range.  Can it even 
> -do- ranges?

No, it can't.

> Closest I've got is this:
>    compctl -k "(1-`cd-discid /dev/cdrom | cut -f2 -d' '`)" playcd
> but that just matches on an array with one member, being "1-18" or
> whatever.  Not a range.
> 
> Any ideas?

If you don't have braceccl set, the cleanest solution would probably
use a function:

  compctl -K comp_tracks playcd
  comp_tracks() {
    setopt localoptions braceccl
    reply=( {1-$(cd-discid /dev/cdrom | cut -f2 -d' ')} )
  }

If you have braceccl set, something like this should do the job:

  compctl -s '{1-$(cd-discid /dev/cdrom | cut -f2 -d' ')}' playcd



Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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