summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Completion/Unix/Type/_domains20
1 files changed, 20 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_domains b/Completion/Unix/Type/_domains
new file mode 100644
index 000000000..42a0966dd
--- /dev/null
+++ b/Completion/Unix/Type/_domains
@@ -0,0 +1,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=( "${(@)_cache_domains:#[ 	]#}" )
+    fi
+  fi
+  domains=( "$_cache_domains[@]" )
+fi
+
+_wanted domains expl domain \
+    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a domains