Open ivomarino opened 8 years ago
Here's an initial version of a plugin which adds zsh completion for options and for SSH hosts: https://gist.github.com/ocean90/3e5da3c526c66144eab3a78b0101b2ec
Copy the file into ~/.oh-my-zsh/plugins/assh/_assh
and add assh
to the plugins
list in your ~/.zshrc
file.
➜ ~ ssh .wp.dev[tab]
37.wp.dev 41.wp.dev 45.wp.dev build.wpmu.dev git.wp.dev
38.wp.dev 42.wp.dev 46.wp.dev develop.wp.dev glotpress.wp.dev
39.wp.dev 43.wp.dev build.wp.dev develop.wphhvm.dev shared.wp.dev
40.wp.dev 44.wp.dev build.wphhvm.dev develop.wpmu.dev
➜ ~ assh -[tab]
--config -c -- location of config file
--debug -D -- debug mode
--help -h -- show help
--verbose -V -- verbose mode
--version -v -- print the version
To do: Add support for the commands (info, config, sockets)
great one, will test it, thanks @ocean90.
I just added
assh wrapper ssh
}
to my zshrc and it works as is for ssh hosts.
Another version: Falkor ZSH completion file _assh
to handle the commands of assh
. For host completion, as indicated by @cnf , it is sufficient to add the wrapper with ssh.
@Falkor Thanks, works like a charm! Could you please elaborate on the host completion part? Where do I have to add the line which @cnf has posted? I'm confused by the closing bracket there. Any help would be appreciated.
Edit: To get host completion working with you file I had to change '*:: :->options' && ret=0
to '*:host:_hosts' && return 0
.
If you remove the options
line, then you never enter the case ... (options) ... esac
part with permit to have completion also on the subcommands ;)
I do not see how to properly integrate host completion at this level (actually, I personally don't see it as critical) thus the wrapper command suggested by @cnf is probably sufficient. Not sure however how it is compliant with any completion file -- I'm not enough advanced with zsh to know it.
@Falkor The question is, what is this wrapper command you're talking about? :) I already have alias ssh="assh wrapper ssh"
in my zshrc file so I guess it must be something else.
Strangely for me simply having the wrapper worked fine for host completion when I first started messing with assh, probably when the config was simpler. Now though I get no host completion at all.
@ocean90 I updated my completion file to include host completion upon assh [...] connect <tab>
-- see _assh
line 51
@Falkor Thanks, but I want to have it for the regular ssh
command/alias. I guess we'd have to do the same for assh wrapper ssh <tab>
?
$ assh wrapper
NAME:
assh wrapper - Initialize assh, then run ssh/scp/rsync...
USAGE:
assh wrapper command [command options] [arguments...]
COMMANDS:
ssh Wrap ssh
OPTIONS:
--help, -h show help
@Falkor This is working for me: https://gist.github.com/ocean90/31371768e6b6f47e06feb3ba34906361/revisions#diff-918a0e7065f6765a4de05d48967c1347
Excellent, I'll update my own accordingly
As in topic, is this actually working for someone? We're on oh-my-zsh here, thanks for info.