Zsh Mailing List Archive
Messages sorted by:
Re: autocompletion with ssh and .ssh/config
- X-seq: zsh-workers 28086
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: David Duponchel <d.duponchel@xxxxxxxxx>
- Subject: Re: autocompletion with ssh and .ssh/config
- Date: Sun, 18 Jul 2010 01:21:59 -0400 (EDT)
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <AANLkTikyZ8XZ_A8yGIQN2PRSXoA1Un6ZNdI6GLDzQpNN@xxxxxxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AANLkTikyZ8XZ_A8yGIQN2PRSXoA1Un6ZNdI6GLDzQpNN@xxxxxxxxxxxxxx>
On Sun, 18 Jul 2010, David Duponchel wrote:
> I have some hosts defined in my .ssh/config file. Example :
> Host bar
> HostName 220.127.116.11
> Host baz
> HostName 18.104.22.168
> When I type ssh <tab>, only my users and hosts in /etc/hosts are
> displayed (my .ssh/config is ignored).
> With ssh ba<tab> the autocompletion is correctly done and propose bar
> and baz.
> Same behavior with ssh user@<tab> and ssh user@ba<tab>
> Expected : Hosts from ssh/config are proposed by the autocompletion
> with the other hosts.
> I did some research and the root of the problem seems to be in
> Completion/Unix/Command/_ssh, function _ssh_hosts : the function
> exists too early (before reading ssh/config).
> Used .zshrc :
> autoload -U compinit
> Tested env : zsh 4.3.10 and 4.3.10-dev-1, OS : Archlinux.
Confirmed with a pretty recent git build.
Host from ~/.ssh/config aren't proposed until hosts found from other
methods are exhausted. The biggest reason that seems wrong (IMO) is
that 'other methods' includes ~/.ssh/known_hosts. So, a host I've never
ssh'ed to won't be offered until I've ssh'ed to it.
With 'acerwin.internal' and 'acerlin.internal' as hosts that show up
already, I tested by adding, to an already large ~/.ssh/config:
And editing ~/.ssh/known_hosts to add acerjjjkh as an alias of some
Then acerlin, acerwin, and acerjjjkh are offered in the initial list,
but acerjjjconfig isn't offered until I type the 'c' (which is also
annoying because acerj<Tab> completes at that point unambiguously to
The two _combinations branches in _ssh_hosts that use the user-hosts tag
seem to be returning intentionally if anything matches. Removing the '
&& return' from each seems to make things better. But, I'm not sure of
the use-case that those are supporting.
Another thing to note is that I couldn't get it to recognize HostName
when HostName was indented as David had it. E.g. adding:
only added acerjjjconfig to the list of completions.
Messages sorted by: