Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a hosts file to block ads/malware domains. When I use ssh or scp in zsh and try to tab-complete, it takes a good 5-10 seconds before anything appears and what does appear is usually a list of 20+ domains I have blocked, and buried in there is the file I need.

I've search online quite a bit, and found helpful hints of how to add this sort of auto-completion, but I can't figure out how to remove it. I basically never want the tab-complete to search my hosts file (I use known-hosts for the servers I actually do want to tab-complete to).

This is on OS X.

share|improve this question

migrated from stackoverflow.com Jun 1 '11 at 13:31

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

Try adding the following to your zshrc

zstyle ':completion:*' hosts off
share|improve this answer
Or zstyle -e ':completion:*' hosts 'reply=($myhosts)' to complete hosts from an array of your choosing (that example is from zshcompsys(1). – Gilles Jun 1 '11 at 22:22
you can also use zstyle -e ':completion:*' hosts /my/special/hostfile – echox Jun 2 '11 at 10:37
Thanks a lot, I have thousands of hosts in my hosts file and it save me a lot of tabs ;) – Dorian Sep 21 '11 at 9:20
Doesn't work. It causes ZSH to complete off as a host. This works though: zstyle -e ':completion:*' hosts 'reply=()' – ThiefMaster Feb 15 '15 at 1:11
None of the above worked for me. Adding hosts after the star did the trick though: zstyle ':completion:*:hosts' hosts off – Jonas Kalderstam Aug 18 '15 at 1:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.