autoload -U compinit compinit #zmodload zsh/files bindkey -e prompt='%h %n@%m%(#.#.$) ' make_p () { local x i x="$1" [ -f $x ] || return 0 for i; do [ -f $i -a $i -nt $x ] && return 0 done return 1 } cache_hosts_file="$HOME/.cache_hosts" known_hosts_file="$HOME/.ssh/known_hosts" print_cache_hosts () { if [ -f $known_hosts_file ]; then awk '{ if (split($1, a, ",") > 1) for (i in a) { if (a[i] ~ /^[a-z]/) print a[i] } else print $1 }' $known_hosts_file fi } update_cache_hosts () { print_cache_hosts | sort -u > $cache_hosts_file } make_p $cache_hosts_file $known_hosts_file && update_cache_hosts _cache_hosts=( $(cat $cache_hosts_file) )