about summary refs log tree commit diff
path: root/Completion/User/_domains
blob: 9bd94a4fd8799184a491a30608fab4f2384686e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#autoload

local expl domains tmp

if ! zstyle -a ":completion${curcontext}:domains" domains domains; then
  if (( ! $+_cache_domains )); then
    _cache_domains=()
    if [[ -f /etc/resolv.conf ]]; then
      while read tmp; do
        [[ "$tmp" = (domain|search)* ]] &&
            _cache_domains=( "$_cache_domains[@]" "${=${tmp%%[ 	]#}#*[ 	]}" )
      done < /etc/resolv.conf
      _cache_domains=( "${(@)_nslookup_domains:#[ 	]#}" )
    fi
  fi
  domains=( "$_cache_domains[@]" )
fi

_wanted domains expl domain &&
    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$domains[@]"