5

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.

9

Try adding the following to your zshrc

zstyle ':completion:*' hosts off
5
  • 1
    Or zstyle -e ':completion:*' hosts 'reply=($myhosts)' to complete hosts from an array of your choosing (that example is from zshcompsys(1). – Gilles 'SO- stop being evil' Jun 1 '11 at 22:22
  • you can also use zstyle -e ':completion:*' hosts /my/special/hostfile – echox Jun 2 '11 at 10:37
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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