zshrc: read host for ssh command completion from config
authorChristian Sturm <reezer@reezer.org>
Sat, 7 Feb 2015 13:03:10 +0000 (14:03 +0100)
committerFrank Terbeck <ft@grml.org>
Sat, 7 Feb 2015 15:49:36 +0000 (16:49 +0100)
etc/zsh/zshrc

index 09ebfc7..2ab3f85 100644 (file)
@@ -764,14 +764,17 @@ grmlcomp() {
 
     # host completion
     if is42 ; then
+        [[ -r ~/.ssh/config ]] && _ssh_config_hosts=(${${${(@M)${(f)"$(cat $HOME/.ssh/config)"}:#Host *}#Host }:#*[*?]*}) || _ssh_config_hosts=()
         [[ -r ~/.ssh/known_hosts ]] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
         [[ -r /etc/hosts ]] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
     else
+        _ssh_config_hosts()
         _ssh_hosts=()
         _etc_hosts=()
     fi
     hosts=(
         $(hostname)
+        "$_ssh_config_hosts[@]"
         "$_ssh_hosts[@]"
         "$_etc_hosts[@]"
         localhost