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

Re: Ssh completion from ~/.ssh/config



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