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

SSH autocompletion issue #2414

Closed
ibc opened this issue Jan 9, 2014 · 7 comments
Closed

SSH autocompletion issue #2414

ibc opened this issue Jan 9, 2014 · 7 comments

Comments

@ibc
Copy link

ibc commented Jan 9, 2014

OSX 10.9.1 and zsh 5.0.4 installed with brew. Also installed zsh-completions and, of course, oh-my-zsh which is properly working, except this issue:

I've previously wrote "ssh myhost.com" to connect to my server. Then, if later I write "ssh myhost.mydoma" and press TAB, I do NOT get autocompletion. Using Bash I get autocompletion.

Second issue. If I add a host entry in ".ssh/config":


Host home
    hostname    myhost.com
    port        222
    user        alice

and then I type (using zsh) "ssh myh" and press TAB I get something ugly and invalid:

ssh \[my.host\]:222

Again, it properly works if I switch to Bash.

@ncanceill
Copy link
Contributor

Your first issue is just a missing feature, feel free to implement it yourself.

Your second issue is disturbing, but there is an easy workaround: just complete the alias of the host. Here it is home, so you can do:

ssh ho[TAB]

and it will complete to:

ssh home

ncanceill added a commit to ncanceill/oh-my-zsh that referenced this issue Feb 2, 2014
…so required for system known hosts, partially fixes ohmyzsh#2414
@ncanceill
Copy link
Contributor

So I found the bug causing your second issue and submitted a fix: #2489

Fell free to comment. Maybe the colon and port number should also be removed?

About your first issue: this behavior indicates that the host is not in your known_hosts files. Can you please check them when the issue occurs?

@ibc
Copy link
Author

ibc commented Feb 11, 2014

Sorry for the delay in the response.

About the first issue: I think you are right. If I can reproduce it again I will re-open it.

About the second issue: The pull request #2489 does fix the brackets problem, and indeed, it should remove the port number since it is wrong. BTW it would be great if it would add "-p PORT" (for ssh) and "-P PORT" (for scp) if port appears in the know_files entry :)

@ncanceill
Copy link
Contributor

Thanks for the update.

Good to know the patch works. I will update it to also remove the port number, but I am afraid that adding the -p 1234 will not be easy.

@ibc
Copy link
Author

ibc commented Feb 12, 2014

Thanks a lot!
Don't worry for the "-p PORT" feature, it would be too much cool ;)

@ncanceill
Copy link
Contributor

@ibc OK now #2489 properly trims the port number

For info, I tried to implement your feature: replacing : by -p. But it does not work because completion always escapes, so it yields ssh address\ -p\ port and the backslashes make ssh see that as the whole address.

In the end, as soon as you are going to connect multiple times to a specific host, I strongly recommend that you create an alias in your .ssh/config and complete for the alias instead of the address. When you use the alias, ssh reads your config, and there is no need to specify the port number or anything else.
If you just want to complete for a recent host without an alias, you will have to remember the port number yourself.

@ibc
Copy link
Author

ibc commented Feb 13, 2014

Yes, I already make extensive usage of .ssh/config :)

Let me close the issue as it is 100% fixed. Thanks a lot.

@ibc ibc closed this as completed Feb 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants