zsh-users
 help / color / mirror / code / Atom feed
* How to turn off NIS hosts completion?
@ 2004-12-08 20:02 Iain MacDonnell
  2004-12-09 10:42 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Iain MacDonnell @ 2004-12-08 20:02 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]


I've been a zsh user since the mid 90's, but I haven't been able to keep
up with some of the newer developments. zstyle frightens me with its
apparent complexity. I've now hit a problem that's so frustrating that
I'm about ready to ditch zsh and go to bash... unless someone can help?

Completion for ssh and friends (notably scp) attempt to look up NIS
nowadays (I'm using zsh 4.2.0), but when you have 40,000 entries in your
NIS passwd map, this is not a fun experience. Hitting "scp blah<TAB>"
causes the shell to hang for a couple of minutes - there doesn't appear
to be any way to interrupt it.

Is there a way to turn off this NIS lookup for users and hosts? I've
tried defining my own, with a snippet plagiarized from someone else's
config, courtesy of google:

local _myhosts _myusers

_myhosts=($(<~/.zsh/hosts) 
${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
_myusers=($(<~/.zsh/users))

zstyle ':completion:*' users $_myusers
zstyle ':completion:*' hosts $_myhosts

and that works so long as I have typed the first few letters of one of
those users or hosts, but if I've typed something that doesn't match,
the NIS lookup, and resulting hang, still occur,

Please help .. before I jump ship to bash .. I really don't want to ...

TIA,

     ~Iain



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 2951 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to turn off NIS hosts completion?
  2004-12-08 20:02 How to turn off NIS hosts completion? Iain MacDonnell
@ 2004-12-09 10:42 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2004-12-09 10:42 UTC (permalink / raw)
  To: zsh-users

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@csr.com>                  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
**********************************************************************


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-09 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-08 20:02 How to turn off NIS hosts completion? Iain MacDonnell
2004-12-09 10:42 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).