Zsh Mailing List Archive
Messages sorted by:
Re: Using the same completion function for various commands
- X-seq: zsh-users 15614
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: mrichter@xxxxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: Using the same completion function for various commands
- Date: Mon, 6 Dec 2010 15:54:20 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=5UaF2WFzfNNSz5vaJ36KT2IdrX14ud5HiI8u2v/C4SI=; b=rHl4QBDYB7z+JnNk1pXxPLQXnogVt1hnBsJA5YgwZm5jAE4opPUMKVfO7FuzulKqYo jrnzWX5v258tUFgqUXStZDKZYpXYhokKRBIhP6YvPNGx4I6hQ/vrxKsWSatIolGxIHTn siRab1WvEXLtKmx/qG5VzC8wES8Hh3yLEMe6A=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=EpksyrL4fCVMlHZ0sq9c01nwefK0cFOMTKVa7HqTbcj2c38iGb1JVMO2yKtXqbPwe9 un74v/afC8fJyQBdHCPxsOHvkH8eJrvW5EHcvd8FBEyJdV3O3k/F8E07Twcci9lOWF6a O7iHdzGoPWILhE4DOjTJJG72l08nRvecPvb5A=
- In-reply-to: <201012061512.21791.mrichter@xxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <201012061512.21791.mrichter@xxxxxxxxxxxxxxxxxxxxxxxx>
On 6 December 2010 15:12, Martin Richter
> I'm searching the documentation for quite a while now but can't figure out how
> to do the following:
> I wrote a completion function which resides somewhere in $fpath, let's call it
> _foo. But I don't want to have it applied on the command foo only. I want to use
> it on all commands matching a certain pattern, e.g. foo_1, foo_2, ... (or foo_*
> for short). Is it possible to define a context for this (like
> :completion::complete:foo_*::) and use zstyle to bind this completer to it?
> Unfortunately I couldn't figure out how.
> Âzstyle "*" completer _<TAB>
> only tells me about some built-ins.
> Thank you very much and please forgive me in case I oversaw something obvious in
> the documentation.
#compdef names... [ -[pP] patterns... [ -N names... ] ]
The file will be made autoloadable and the function
defined in it will
be called when completing names, each of which is either
the name of a
If the #compdef line contains one of the options -p or
-P, the words
following are taken to be patterns. The function will
be called when
completion is attempted for a command or context that
matches one of
the patterns. The options -p and -P are used to
specify patterns to
You can also do this in your .zshrc instead of in the completer if you
wish, just write
compdef _foo -p 'foo_*'
At least that's what the documentation says, it doesn't seem to work that well.
Messages sorted by: