2020-06-20 11:11:09 +00:00
|
|
|
local REPLY
|
|
|
|
zstyle -s ':custom:prompts:weather' location REPLY
|
2020-07-24 20:49:14 +00:00
|
|
|
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": {"min": .min_temp, "max": .max_temp}, "icon": .weather_state_abbr}')
|
2020-06-20 11:11:09 +00:00
|
|
|
if [ ! -z $result ]; then
|
|
|
|
local ico=$(print $result | jq -r '.icon')
|
2020-07-24 20:49:14 +00:00
|
|
|
typeset -g _cprompts_weather=($(jq -r '.temp.min' <<< $result) $(jq -r '.temp.max' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
|
|
|
|
print ${_cprompts_weather} > $tmpfile
|
2020-06-20 11:11:09 +00:00
|
|
|
fi
|