Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Ssh completion from ~/.ssh/config
- X-seq: zsh-users 20107
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: "Vadim A. Misbakh-Soloviov" <mva@xxxxxxxx>
- Subject: Re: Ssh completion from ~/.ssh/config
- Date: Tue, 7 Apr 2015 17:53:43 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3fK4rdVzQ49Uwsucn7FnxT7ojdYf3I2M36XL7INbCLk=; b=I/ZC8hJZn5RpM8qKDfFwzak7hJoan/OwixffDxwn8a3ORZAc/scpUTXtJRwNZxkh5q aOsfs/18u5DuqPkVdSZo2wDEiVf3t8JO+y83Uqss9Ut0gSLI/7JeAy/HEJm3GOKkEU5b 1Mnta4Rs2G43xdqqvC3JH7qrsCIyP5uLCwsE7piX1tcS7AfaIkrgS5c8gwk4FbeqCkZn 2crVrXyxLa5PGIUdBgY64JAp4KkTBFi0r8VA6xPMD9fisj0LpnsQP6jS6D7AB4GO4VtQ fEwwtNrVFgKAvVQNWRAljJSHfr4UI7MJhY5YATSSmG/1U6Gj50F6A558DOR682rbpcce yBCA==
- In-reply-to: <1797284.9M4pHoONQN@note>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg-8fQyOsYLHwYKoDx8DxOsReeZzfhtoi5fV_DDUQ-ziZA@mail.gmail.com> <1797284.9M4pHoONQN@note>
On Tue, Apr 7, 2015 at 4:27 PM, Vadim A. Misbakh-Soloviov <mva@xxxxxxxx> wrote:
> ```
> # Hostnames completion.
> zstyle -e ':completion:*:hosts' hosts 'reply=(
> ${${${${${(f)"$(<${HOME}/.ssh/known_hosts)"//\[/}//\]:/ }:#[\|]*}%%\
> *}%%,*}
> ${${${(@M)${(f)"$(<${HOME}/.ssh/config)"}:#Host *}#Host }:#*[*?]*}
> ${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}#*[[:blank:]]}}
> )'
> zstyle ':completion:*:*:*:hosts' ignored-patterns 'ip6*' 'localhost*'
>
>
> ```
You'll probably want these lines inside an if test -f ~/.ssh/config,
as old versions of zsh will abort execution if $(< fails to find the
file. (This bit me once a few years ago).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author