Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH _hosts: can complete hosts listed on ~/.ssh/config



Tatsuki Sugiura wrote:
> Hello.
> 
> Usually, "/etc/hosts" dos not contain hostname to wish to complete.
> This pactch parse ~/.ssh/config and pick up hosts listed as "Host"
> or "HostName".

Picking up hosts from a "Host" line is perhaps not wise because it can
contain ssh specific nicknames and wildcards. I'd be more inclined to
use ~/.ssh/known_hosts.

You can use a style to specify your hosts for ssh:
zstyle ':completion:*:(ssh|scp):*:my-accounts' users-hosts user@host

Or use this:
  ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}
to set the hosts style.

That said, I appreciate that it could be more intelligent out-of-the-box.
The way I envision that eventually working involves integrating with user
and port completion more flexibly than _combination and it isn't trivial.

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author