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

DNS completion



I wrote some code to support DNS zonetransfers in host completion.

It's a simple replacement for _hosts and it is not quite perfect yet.

You have to put a "search domain.com" line into /etc/resolv.conf and
need to have the "host" utility installed on your system.

Please let me know, what you think about it.

Also, I have two questions: How can I make libc calls directly from the
shell? You guess it: gethostbyname(2). Would it be possible to
substitute the awk usage with zsh parameter expansion?

please use reply-to, I'm not on the list.

-- 
1024D/DC805C44 2000-07-06 http://cran.ath.cx/~seb/publicpgpkey.asc 
key fingerprint A079 88E9 3617 838D ED65  A7D1 277D D529 DC80 5C44
#compdef ftp ping rwho rup xping traceroute host

local expl hosts

if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
  (( $+_cache_hosts )) ||
      : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(host -l $(awk '/search/ { print $2 }' < /etc/resolv.conf) 2>/dev/null | awk '{ print $3, $1}')"}%%\#*}##[:blank:]#[^[:blank:]]#}}}

  hosts=( "$_cache_hosts[@]" )
fi

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


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