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

Re: Using the same completion function for various commands



On Mon, 06 Dec 2010 20:39:21 +0100
Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> Peter wrote:
> > Why we would ever prefer $words[1] to $service, when this seems
> > to be what $service is for?
> 
> Aside from the case Bart mentioned, there's also cases like:
>   compdef gdu=du

It looks like you can't in general distinguish between two ways of using
the service:

- A command (gdu) is an instance of a basic command (du) for which
completion exists, but under a different name (as above).  The basic
command might exist but your best bet for picking the right version
is to run the new instance.

- A command has some behaviour related to, or acts as a front end for, a
basic command but possibly doesn't fully implement it and might not be
useful for finding out the version of the interface.  Then you'd need to
run the basic command.

In the first case you have the simple alternative of defining

#compdef gdu
_du "$@"

which fixes the service for you.

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


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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