c4434d2ddedd62737ad3f99111ef47d722e2b74e

Author
Sébastien M-B <essembeh@gmail.com>
Committer
Sébastien M-B <essembeh@gmail.com>
Date

Message

Update completion for SSH

Add all hosts found in ~/.ssh/config.
Tip found on: http://www.nerux.org/wiki/OpenSSH#coupler_avec_zsh_completion

Diff

 1diff --git a/lib/completion.zsh b/lib/completion.zsh
 2index b3cc918229ce3cdf60f6434cda1ecf1e7a385a77..dab9bb1d3f1c2624e15e76176bdcbe22521a3e7f 100644
 3--- a/lib/completion.zsh
 4+++ b/lib/completion.zsh
 5@@ -33,14 +33,17 @@ cdpath=(.)
 6 
 7 # use /etc/hosts and known_hosts for hostname completion
 8 [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
 9+[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
10 [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
11 hosts=(
12+  "$_ssh_config[@]"
13   "$_ssh_hosts[@]"
14   "$_etc_hosts[@]"
15   `hostname`
16   localhost
17 )
18 zstyle ':completion:*:hosts' hosts $hosts
19+zstyle ':completion:*' users off
20 
21 # Use caching so that commands like apt and dpkg complete are useable
22 zstyle ':completion::complete:*' use-cache 1