I'm not aware of an easy method to enable completion for a custom command. Assuming you've got a command foo
with a bunch of allowable arguments bar
, bas
or baz
, then the completion is easy: you can either have foo bar
, foo bas
, or foo baz
. If they're not or
'd, though, you could have any combination of the three.
It gets somewhat worse when you've got a 'depth' of more than 1 (bar
can take arguments car
, cas
and caz
, for example).
In zsh
, my general understanding is that completion for commands is detailed in completion functions
. These functions are application specific, because the arguments for each application are specific to those applications. As an example, the tmux
(a terminal multiplexer, similar to screen
, in case you're not familiar) has a completion function that's fairly complex: here's a link.
If you want to write your own completion functions, the documentation is available and accessible. Here are a bunch of links that I'm (slowly) working my way through - they'll definitely tell you how to get completion working, but there's a lot of reading. The Z-Shell is a complex beast.
You're specifically interested in enabling completion for hostname-like arguments, and you've singled out ssh
as the idea. The zsh
completion function for ssh
is defined in Completion/Unix/Command/_ssh
, if you've got the ZSH source. If not, here's a link.
Of course, this SO question is rather similar. compdef
alone may do what you want, if myscript
and ssh
parameters are identical enough.