2020-06-20 11:11:09 +00:00
|
|
|
([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
|
|
|
|
local tmpfile=${CACHEPATH}/weather
|
|
|
|
local -a stats
|
|
|
|
|
|
|
|
# Fancy stuff
|
|
|
|
local -A icons
|
|
|
|
local -A colors
|
|
|
|
icons[c]=''
|
|
|
|
colors[c]="yellow"
|
|
|
|
icons[lc]=''
|
|
|
|
colors[lc]="yellow"
|
|
|
|
icons[hc]=''
|
|
|
|
colors[hc]="cyan"
|
|
|
|
icons[s]='🌢'
|
|
|
|
colors[s]="yellow"
|
|
|
|
icons[lr]='🌢'
|
|
|
|
colors[lr]="cyan"
|
|
|
|
icons[hr]=''
|
|
|
|
colors[hr]="blue"
|
|
|
|
icons[t]=''
|
|
|
|
colors[t]="white"
|
|
|
|
icons[h]=''
|
|
|
|
colors[h]="white"
|
|
|
|
icons[sl]=''
|
|
|
|
colors[sl]="blue"
|
|
|
|
icons[sn]=''
|
|
|
|
colors[sn]="white"
|
|
|
|
|
|
|
|
if [ ! -v _cprompts_weather ]; then
|
|
|
|
zstat -A stats +mtime -- $tmpfile 2>/dev/null
|
2020-06-20 22:10:44 +00:00
|
|
|
if [ $stats[1] -lt $(($epochtime[1]-21600)) ]; then
|
2020-06-20 11:11:09 +00:00
|
|
|
cprompts:cache:async:weather &!
|
|
|
|
else
|
|
|
|
typeset -g _cprompts_weather=($(< $tmpfile))
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
|