2020-06-20 11:11:09 +00:00
|
|
|
local REPLY
|
|
|
|
zstyle -s ':custom:prompts:weather' location REPLY
|
2020-09-26 17:17:43 +00:00
|
|
|
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_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-09-26 17:17:43 +00:00
|
|
|
typeset -g _cprompts_weather=($(( int(rint($(jq -r '.temp' <<< $result))) )) ${colors[$ico]:-white} ${icons[${ico:-X}]})
|
2020-07-24 20:49:14 +00:00
|
|
|
print ${_cprompts_weather} > $tmpfile
|
2020-06-20 11:11:09 +00:00
|
|
|
fi
|