Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Using another command's completion function with an alias
- X-seq: zsh-users 14563
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Using another command's completion function with an alias
- Date: Thu, 12 Nov 2009 14:42:43 -0500 (EST)
- In-reply-to: <chaz20091112192523.GA4367@xxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.0911121316020.26715@xxxxxxxxxxx> <chaz20091112192523.GA4367@xxxxxxxxxxx>
On Thu, 12 Nov 2009, Stephane Chazelas wrote:
> 2009-11-12 14:00:56 -0500, Benjamin R. Haskell:
> [...]
> > alias noagent='env -u SSH_AGENT_PID -u SSH_AUTH_SOCK'
> >
> > But, compdef noagent=-command- doesn't have the desired effect. I
> > instead get the completion for 'env':
> >
> > $ noagent <C-x><h>
> > tags in context :completion::complete:-u::
> > all-files (_files _default (eval))
> > tags in context :completion::complete:env::
> > argument-rest (_arguments _env (eval))
> >
> > Obviously my completion-fu is still in its infancy. Is there something
> > simple to fix the 'alias' version?
> [...]
>
> I don't have the answer to that exact question, but I think that
> if you used a function instead of an alias, your compdef trick
> would work. Like:
>
> noagent() env -u SSH_AGENT_PID -u SSH_AUTH_SOCK "$@"
> compdef noagent=-command-
Hmm. Interesting. Thanks.
> BTW:
>
> Manual> 6.7 Aliasing
> Manual> ============
> Manual>
> Manual> Every token in the shell input is checked to see if there
> Manual> is an alias defined for it. If so, it is replaced by the
> Manual> text of the alias if it is in command position (if it
> Manual> could be the first word of a simple command), or if the
> Manual> alias is global. If the text ends with a space, the next
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Manual> word in the shell input is treated as though it were in
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Manual> command position for purposes of alias expansion.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> So you may prefer:
>
> alias noagent='env -u SSH_AGENT_PID -u SSH_AUTH_SOCK '
Also interesting. On first read, I too thought this might help. But, the
problem is 'for purposes of alias expansion'.
I.e. that section allows:
$ alias A='echo foo'
$ alias B='echo foo '
$ A A
foo A
$ B B
foo echo foo
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author