Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to turn off NIS hosts completion?



Iain MacDonnell wrote:
> Is there a way to turn off this NIS lookup for users and hosts?

There's a nasty but simple hack to turn off user name lookup.  The shell
does the lookup via the special variable userdirs in the zsh/parameter
module.  This declares itself in such a way that it can be overridden by
a local user definition.  You can persuade the completion system to
override it with an empty array by adding the following code to your own
initialisation.  It goes at some point after the completion system has
been loaded by "compinit":

  zmodload -i zsh/parameter
  _comp_setup+=$'\ntypeset -a userdirs'

assuming zsh 4.2, else you need to spell out the second line

  _comp_setup=$_comp_setup$'\ntypeset -a userdirs'

There's no such variable for hosts.  As far as I could see from the
code, hosts are never looked up from NIS if the hosts style is set, as
you have.  However, you can make sure by redefining _hosts, stripping
out the hairy middle chunk:


#compdef ftp ping rwho rup xping traceroute host aaaa zone mx ns soa txt

local expl tmp
local -a hosts

zstyle -a ":completion:${curcontext}:hosts" hosts hosts

_wanted hosts expl host \
    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a hosts


You can then put this in your $fpath earlier than the standard
completion directories.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author