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

Using another command's completion function with an alias



Back in March, Bart Schaefer recommended the following useful advice for 
getting 'sshfs' to use the completion for 'scp':

compdef sshfs=scp

I have several commands that I use regularly that do some setup of the 
environment or other kinds of filtering.  For example, daemontools' 
fixcrio fixes up LF line endings to emit CRLF:

Usage is roughly: fixcrio program [args]
E.g. fixcrio nc mail.example.com smtp

I managed to get the ones that are commands to work the way I want them to 
by using:

compdef commandname=-command-

I also have some that are straightforward enough to set them as 
aliases.

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?

Also, commandname=-command- works fine for my purposes.  But, '-command-' 
is too general: for starters, it also picks up builtins and aliases.  Is 
there something better I should use?

Thanks,
Ben



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