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

Re: Question about _directories



On Wed, 16 Apr 2008 18:56:09 +0200
Mark Daniel Reidel <mark@xxxxxxxxxxx> wrote:
> I'm currently writing a file for tab-completion of a script and I have
> a problem: on a certain parameter, it has to accept all
> sub-sub-directories of /usr/ports. So /usr/ports/a/b/ is good,
> but /usr/ports/a/b/c should not be found. Of course /usr/ports/a<tab>
> should list everything starting with a as well, but how can I limit
> that it should only work 2 directories deep with _directories?

I think a fairly simple wrapper will work.  Try something like:

if [[ $PREFIX = /usr/ports/*/*/* ]]; then
  return 1
else
  _directories
fi

Then point completion for the script at this function instead of
_directories.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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