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

Re: Completion on simple commande



2010/8/12 Peter Stephenson <Peter.Stephenson@xxxxxxx>:
> On Thu, 12 Aug 2010 11:11:11 +0200
> Michel <michel.barret@xxxxxxxxx> wrote:
>> I use an zsh function to launch the graphical application. But I don't
>> know how have the completion on my function.
>>
>> My function is :
>> function start (){
>> Â Â $@ > /dev/null 2> /dev/null &
>> }
>>
>> And I want can type :
>> start fire<tab>
>
> "man zshcompsys" is the place to start, but working that way it'll take a
> while before you get to the point where you can answer questions like this.
>
> First you'll need to start the completion system; it's not clear if you've done
> that. ÂIf you haven't, put this in your ~/.zshrc:
>
> autoload -Uz compinit
> compinit

This configuration is already applied.

> Then the simplest answer to the immediate question is to add the following
> line:
>
> compdef _precommand start

Thanks it's exactly that !

> That makes "start" behave like other command words that take a complete
> command line following.
>
> By the way, you might want to put the $@ in double quotes:
>
> function start (){
> Â Â"$@" > /dev/null 2> /dev/null &
> }
>
> The difference is that this won't remove any zero-length arguments to the
> command, e.g. a '' on the command line. ÂThat's not a typical problem with
> the sort of use you have, however.

Ok I make this modification thanks you and Frank Terbeck.



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