ZSHFiles/custom/segments/prompt_c_covid_19

15 lines
484 B
Plaintext

([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
local tmpfile=${CACHEPATH}/covid
local REPLY
zstyle -s ':custom:prompts:covid' country REPLY
local -a stats
if [ ! -v _cprompts_covid ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then
cprompts:cache:async:covid &!
else
typeset -g _cprompts_covid=$(< $tmpfile)
fi
fi
[ -v _cprompts_covid ] && p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}"