Include avahi host completions in known hosts completions no matter if we have known hosts or ssh config files or not.

master
Ville Skyttä 2009-12-13 11:33:54 +02:00
parent b72a0f6e26
commit a358902e90
1 changed files with 12 additions and 13 deletions

View File

@ -1351,25 +1351,24 @@ _known_hosts_real()
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$hosts" -- "$cur" ) )
fi
# Add hosts reported by avahi, if it's available
# and if the daemon is started.
# The original call to avahi-browse also had "-k", to avoid
# lookups into avahi's services DB. We don't need the name
# of the service, and if it contains ";", it may mistify
# the result. But on Gentoo (at least), -k isn't available
# (even if mentioned in the manpage), so...
if type avahi-browse >&/dev/null; then
COMPREPLY=( "${COMPREPLY[@]}" $(
compgen -W "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
grep ^= | cut -d\; -f7 | sort -u )" -- "$cur" ) )
fi
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
done
fi
# Add hosts reported by avahi-browse, if it's available.
# The original call to avahi-browse also had "-k", to avoid lookups into
# avahi's services DB. We don't need the name of the service, and if it
# contains ";", it may mistify the result. But on Gentoo (at least),
# -k isn't available (even if mentioned in the manpage), so...
if type avahi-browse >&/dev/null; then
COMPREPLY=( "${COMPREPLY[@]}" $( \
compgen -P "$prefix$user" -S "$suffix" -W \
"$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
grep ^= | cut -d\; -f7 | sort -u )" -- "$cur" ) )
fi
# Add results of normal hostname completion, unless
# `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then