* users@hosts completion
@ 2004-06-27 12:15 Chris Johnson
2004-06-29 16:40 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Chris Johnson @ 2004-06-27 12:15 UTC (permalink / raw)
To: zsh-users
I'm able to get the users-hosts completion for ssh, scp, and so on,
but how can I extend this functionality to my own programs? I've been
through the manual and Google, but no zstyle line has worked for me.
How can I setup users-hosts completion for my specified commands?
Thanks for any help!
--
Chris Johnson
cjohnson AT cs DOT utk DOT edu
http://www.cs.utk.edu/~cjohnson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: users@hosts completion
2004-06-27 12:15 users@hosts completion Chris Johnson
@ 2004-06-29 16:40 ` Bart Schaefer
2004-06-29 21:39 ` Chris Johnson
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2004-06-29 16:40 UTC (permalink / raw)
To: zsh-users
On Sun, 27 Jun 2004, Chris Johnson wrote:
> How can I setup users-hosts completion for my specified commands?
Unfortunately you can't set this up with zstyles only, because it relies
on a special utility function called _combination which has to be called
in the correct way from the function that generates potential matches for
the command in question.
There's a generic function called _user_at_host that does this for the
special case of "user@hostname" arguments, but you still need another
function (which calls e.g. _arguments) to interpret the command line and
call _user_at_host when the cursor is in the correct argument position.
If it happens that your command has argument syntax very similar to one of
the commands that already uses users-hosts completion, then you can tell
the completion system to treat completion for your command exactly the
same as completion for that other command. You do that with a "compdef"
command like so:
compdef mynewcommand=telnet
Otherwise you'll have to delve into the writing of a new completion.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: users@hosts completion
2004-06-29 16:40 ` Bart Schaefer
@ 2004-06-29 21:39 ` Chris Johnson
0 siblings, 0 replies; 3+ messages in thread
From: Chris Johnson @ 2004-06-29 21:39 UTC (permalink / raw)
To: zsh-users
Bart Schaefer wrote:
> On Sun, 27 Jun 2004, Chris Johnson wrote:
>
> > How can I setup users-hosts completion for my specified commands?
>
> Unfortunately you can't set this up with zstyles only, because it relies
> on a special utility function called _combination which has to be called
> in the correct way from the function that generates potential matches for
> the command in question.
[...]
> If it happens that your command has argument syntax very similar to one of
> the commands that already uses users-hosts completion, then you can tell
> the completion system to treat completion for your command exactly the
> same as completion for that other command. You do that with a "compdef"
> command like so:
>
> compdef mynewcommand=telnet
This works beautifully. My command is just a wrapper to scp, written
to help prevent overwriting of files. Too many times I've omitted the
remote destination argument--i.e., scp source1 source2--and overwritten
source2 with source1. (I'm not aware of any interactive option for scp like there is for cp.)
So, this command lends itself perfectly to compdef. I am in your
debt. Thank you!
--
Chris Johnson
cjohnson@cs.utk.edu
http://www.cs.utk.edu/~cjohnson
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-29 21:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27 12:15 users@hosts completion Chris Johnson
2004-06-29 16:40 ` Bart Schaefer
2004-06-29 21:39 ` Chris Johnson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).