Add covid and weather scripts for zsh segments
This commit is contained in:
parent
552ae9cfd0
commit
c83062edce
5
fetch-covid.zsh
Executable file
5
fetch-covid.zsh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
|
||||
typeset -g _cprompts_covid=($(curl -sL https://api.covid19api.com/country/${1:-germany} | jq -e '. |= sort_by (.Date) | .[-1,-2].Active'))
|
||||
[ ! -z $_cprompts_covid[1] ] && <<< ${_cprompts_covid} > ${2:-~/.cache/covid}
|
13
fetch-weather.zsh
Executable file
13
fetch-weather.zsh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/zsh
|
||||
|
||||
([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
|
||||
zmodload zsh/mathfunc
|
||||
typeset -A icons
|
||||
typeset -A colors
|
||||
icons=([c]='' [lc]='' [hc]='' [s]='🌢' [lr]='🌢' [hr]='' [sn]='' [t]='' [h]='' [sl]='')
|
||||
colors=([c]="yellow" [lc]="yellow" [hc]="cyan" [s]="yellow" [lr]="cyan" [hr]="blue" [t]="white" [h]="white" [sl]="blue" [sn]="white")
|
||||
result=$(curl -sL https://www.metaweather.com/api/location/${1:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "hum": .humidity, "icon": .weather_state_abbr}')
|
||||
if [ ! -z $result ]; then
|
||||
ico=$(<<< "$result" jq -r '.icon')
|
||||
<<< "$(( int(rint($(jq -r '.temp' <<< $result))) )) ${colors[$ico]:-white} ${icons[$ico]:-X} $(( int(rint($(jq -r '.hum' <<< $result))) ))" > ${2:-~/.cache/weather}
|
||||
fi
|
Loading…
Reference in New Issue
Block a user