ZSHFiles/custom/segments/prompt_c_weather

12 lines
443 B
Plaintext

([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
local tmpfile=$CACHEPATH/weather
local -a stats
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [ ${stats[1]:-0} -lt $(($epochtime[1]-3600)) ]; then
cprompts:cache:async:weather &!
else
typeset -g _cprompts_weather=($(< $tmpfile))
fi
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"