From 50fd98e5a6c9d7c36b0cc678f577f7ce1d181bea Mon Sep 17 00:00:00 2001 From: Gam <1348187+Y3K@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:59:27 -0600 Subject: [PATCH] fix(ssh): allow multiple definitions per host (#12227) --- plugins/ssh/ssh.plugin.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/ssh/ssh.plugin.zsh b/plugins/ssh/ssh.plugin.zsh index 085e71fa1..b5b050536 100644 --- a/plugins/ssh/ssh.plugin.zsh +++ b/plugins/ssh/ssh.plugin.zsh @@ -4,9 +4,16 @@ # Filter out wildcard host sections. _ssh_configfile="$HOME/.ssh/config" if [[ -f "$_ssh_configfile" ]]; then - _hosts=($(egrep '^Host.*' "$_ssh_configfile" | awk '{print $2}' | grep -v '^*' | sed -e 's/\.*\*$//')) - zstyle ':completion:*:hosts' hosts $_hosts - unset _hosts + _ssh_hosts=($( + egrep '^Host.*' "$_ssh_configfile" |\ + awk '{for (i=2; i<=NF; i++) print $i}' |\ + sort |\ + uniq |\ + grep -v '^*' |\ + sed -e 's/\.*\*$//' + )) + zstyle ':completion:*:hosts' hosts $_ssh_hosts + unset _ssh_hosts fi unset _ssh_configfile