1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 15:21:40 +08:00

fix(ssh): allow multiple definitions per host (#12227)

This commit is contained in:
Gam 2024-02-29 14:59:27 -06:00 committed by GitHub
parent 65b23a3328
commit 50fd98e5a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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