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 14562
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- Subject: Re: Using another command's completion function with an alias
- Date: Thu, 12 Nov 2009 19:25:23 +0000
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=gQJnVcMZPxsWYTCfzApexbcsMKs1ebVqaX7kHgF0rc45OvqVKLd8axl9krvPra3jcxj+VYAtj76o9pBmhR0f0/d3bdfsZAyqSwfcpnwZqOl6qe8MmidTJ+asxOe99jxEudbmS+fIjOLcSdRJJhQanJftuNKXnroQCFgU6mVm1bk= ;
- In-reply-to: <alpine.LNX.2.01.0911121316020.26715@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>
- Mail-followup-to: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.0911121316020.26715@xxxxxxxxxxx>
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-
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 '
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author