about summary refs log tree commit diff
path: root/Completion/User/_hosts
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_hosts')
-rw-r--r--Completion/User/_hosts9
1 files changed, 7 insertions, 2 deletions
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index 83480efe4..196f40c83 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -1,8 +1,13 @@
 #compdef ftp ncftp ping rwho rup xping traceroute host
 
-local expl
+local expl hosts
 
-: ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
+if ! _style -a hosts hosts hosts; then
+  (( $+_cache_hosts )) ||
+      : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
+
+  hosts=( "$_cache_hosts[@]" )
+fi
 
 _wanted hosts expl host &&
     compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]"