Record, recall, share

Sponsored Links

I just installed the homebrew package bash_completion, hoping to get completion on my SSH commands. Unfortunately, I also use my /etc/hosts file as an ad blocker. This results in bash completion completing my ssh hostnames with a ton of ad servers that I put into /etc/hosts, instead of just the few in ~/.ssh/known_hosts that I actually use.

I need a way to exclude these /etc/hosts matches from bash_completion for SSH.

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