about summary refs log tree commit diff
path: root/Completion/Unix/Type/_hosts
blob: 6841f0028d9dbf928ee515f27db455c7431f81b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#compdef ftp rwho rup xping traceroute host aaaa zone mx ns soa txt

local expl hosts tmp

if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
  (( $+_cache_hosts )) ||
      if (( ${+commands[getent]} )); then
	: ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${(f)~~"$(_call_program hosts getent hosts 2>/dev/null)"}##[:blank:]#[^[:blank:]]#}}}
      else
        : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
	if (( ${+commands[ypcat]} )) &&
	    tmp=$(_call_program hosts ypcat hosts.byname 2>/dev/null); then
          _cache_hosts+=( ${=${(f)tmp}##[:blank:]#[^[:blank:]]#} ) # If you use YP
	fi
      fi

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

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