Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh host autocompletion #180

Open
ivomarino opened this issue Nov 8, 2016 · 12 comments
Open

zsh host autocompletion #180

ivomarino opened this issue Nov 8, 2016 · 12 comments
Labels
Milestone

Comments

@ivomarino
Copy link

ivomarino commented Nov 8, 2016

As in topic, is this actually working for someone? We're on oh-my-zsh here, thanks for info.

@ocean90
Copy link
Contributor

ocean90 commented Nov 9, 2016

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)

@ivomarino
Copy link
Author

great one, will test it, thanks @ocean90.

@moul moul self-assigned this Dec 4, 2016
@moul moul added the ready label Dec 6, 2016
@cnf
Copy link
Contributor

cnf commented Jan 3, 2017

I just added

  assh wrapper ssh
}

to my zshrc and it works as is for ssh hosts.

@Falkor
Copy link

Falkor commented Mar 12, 2017

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.

@ocean90
Copy link
Contributor

ocean90 commented Mar 14, 2017

@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.

@Falkor
Copy link

Falkor commented Mar 14, 2017

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.

@ocean90
Copy link
Contributor

ocean90 commented Mar 14, 2017

@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.

@austinbutler
Copy link

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.

@Falkor
Copy link

Falkor commented Mar 16, 2017

@ocean90 I updated my completion file to include host completion upon assh [...] connect <tab>
-- see _assh line 51

@ocean90
Copy link
Contributor

ocean90 commented Mar 16, 2017

@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

@ocean90
Copy link
Contributor

ocean90 commented Mar 16, 2017

@Falkor
Copy link

Falkor commented Mar 17, 2017

Excellent, I'll update my own accordingly

@moul moul removed their assignment Sep 18, 2017
@moul moul modified the milestones: v2.7.0, v2 ✌ Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants