Solution for: #124: Exclude /etc/hosts from bash_completion
COMP_KNOWN_HOSTS_WITH_HOSTFILE excludes /etc/hosts
- yliu on October 29, 2012, 10:47 PM UTC
After digging through the code, it seems that setting the environment variable COMP_KNOWN_HOSTS_WITH_HOSTFILE to an empty value will exclude /etc/hosts from bash completion on SSH. This leaves just the known_hosts file as the source for completions.
On homebrew, for example, adding the line COMP_KNOWN_HOSTS_WITH_HOSTFILE="" before the bash source include
will exclude the misc. matches from completion.
On homebrew, for example, adding the line COMP_KNOWN_HOSTS_WITH_HOSTFILE="" before the bash source include
if [ -f $(brew --prefix)/etc/bash_completion ]; then
COMP_KNOWN_HOSTS_WITH_HOSTFILE='' # this suppresses use of /etc/hosts
. $(brew --prefix)/etc/bash_completion
fi
will exclude the misc. matches from completion.
Comments
The same result can be accomplished by adding
export COMP_KNOWN_HOSTS_WITH_HOSTFILE=""
to your .bashrc, rather than modifying the bash_completion source.
— sean_the_bean on June 20, 2016, 07:52 PM UTC