9 lines
514 B
Plaintext
9 lines
514 B
Plaintext
local REPLY
|
|
zstyle -s ':custom:prompts:weather' location REPLY
|
|
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}')
|
|
if [ ! -z $result ]; then
|
|
local ico=$(print $result | jq -r '.icon')
|
|
typeset -g _cprompts_weather=($(jq -r '.temp.min' <<< $result) $(jq -r '.temp.max' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
|
|
print ${_cprompts_weather} > $tmpfile
|
|
fi
|