summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_ssh28
1 files changed, 17 insertions, 11 deletions
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 6763e24e7..28d2c38e7 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -680,17 +680,23 @@ _ssh_hosts () {
config="$HOME/.ssh/config"
fi
if [[ -r $config ]]; then
- local key hosts host
- while IFS=$'=\t ' read -r key hosts; do
- if [[ "$key" == (#i)host ]]; then
- for host in ${(z)hosts}; do
- case $host in
- (*[*?]*) ;;
- (*) config_hosts+=("$host") ;;
- esac
- done
- fi
- done < "$config"
+ local key line host
+ local -a lines=("${(@f)$(<"$config")}") 2>/dev/null
+ while (($#lines)); do
+ IFS=$'=\t ' read -r key line <<<"${lines[1]}"
+ case "$key" in
+ ((#i)include)
+ lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}") 2>/dev/null;;
+ ((#i)host(|name))
+ for host in ${(z)line}; do
+ case $host in
+ (*[*?]*) ;;
+ (*) config_hosts+=("$host") ;;
+ esac
+ done ;&
+ (*) shift lines;;
+ esac
+ done
if (( ${#config_hosts} )); then
_wanted hosts expl 'remote host name' \
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts