From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26988 invoked by alias); 31 Mar 2013 21:08:23 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17745 Received: (qmail 27940 invoked from network); 31 Mar 2013 21:08:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130331140750.ZM30293@torch.brasslantern.com> Date: Sun, 31 Mar 2013 14:07:50 -0700 In-reply-to: <20130331103044.GA25277@redoubt.spodhuis.org> Comments: In reply to Phil Pennock "Re: How to disable completion of 127.0.0.1 entries from /etc/hosts" (Mar 31, 6:30am) References: <20130331103044.GA25277@redoubt.spodhuis.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: How to disable completion of 127.0.0.1 entries from /etc/hosts MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 31, 6:30am, Phil Pennock wrote: } Subject: Re: How to disable completion of 127.0.0.1 entries from /etc/host } } On 2013-03-31 at 10:29 +0200, vermaden wrote: } > My question is: Is there a way to 'tell' ZSH to NOT complete } > entries beginning with 127.0.0.1 from the /etc/hosts file? } } Seriously, install unbound, use unbound-control and/or home-grown tools } to maintain the list of overrides, make sure the cost of filtering is } only borne once, instead of having zsh also load a 4MB hosts file and } parse it out. Your system will be faster for _every_ hostname-resolving } package, not just zsh. Phil's advice is good, but to more directly answer the question: Zsh only loads from /etc/hosts if it can't find a program named "getent" in your search path. So you can control exactly what zsh sees for the default hosts completion by creating a getent command. If you already have getent, you can write a shell function wrapper to filter it (but zsh decides whether to run it based on the presence of the external command, even though it will call the function if there is one). So something like getent() { command getent "$@" | fgrep -v 127.0.0.1 } or #!/bin/zsh # name this script "getent" and place in a directory in $path for key; do fgrep -v 127.0.0.1 /etc/$key; done You can improve this by testing for the key being "hosts" and do the fgrep only in that case, but it probably isn't going to make that much difference given the rest of the context.