mirror of
https://github.com/jbowdre/dotfiles.git
synced 2025-01-14 13:09:13 +00:00
fish: display weather data from tempest on start
This commit is contained in:
parent
000e9d2dfb
commit
6055f5fb79
1 changed files with 22 additions and 2 deletions
|
@ -2,8 +2,28 @@
|
|||
programs.fish.functions = {
|
||||
# cht.sh integration
|
||||
cht = "curl cheat.sh/$argv";
|
||||
# Disable greeting
|
||||
fish_greeting = "";
|
||||
|
||||
# Display weather from tempest station
|
||||
fish_greeting = ''
|
||||
if test -f "${config.sops.secrets.tempest-station.path}"
|
||||
set station (cat ${config.sops.secrets.tempest-station.path})
|
||||
set token (cat ${config.sops.secrets.tempest-token.path})
|
||||
set wxjson (curl --max-time 2 --compressed -sL "https://swd.weatherflow.com/swd/rest/better_forecast?station_id=$station&token=$token&units_temp=f")
|
||||
if test $status -eq 0; and echo $wxjson | jq empty >/dev/null 2>&1
|
||||
set -l wxdata (echo $wxjson | jq -r '[
|
||||
(.current_conditions.conditions | ascii_downcase),
|
||||
(.current_conditions.air_temperature | round | tostring),
|
||||
(.forecast.daily[0].air_temp_low | round | tostring),
|
||||
(.forecast.daily[0].air_temp_high | round | tostring)
|
||||
] | @tsv' | string split \t)
|
||||
echo -ne "\nwx@home: "; set_color -d green; echo -n "$wxdata[1] and $wxdata[2]°f "; set_color normal
|
||||
echo -n "("; set_color -d blue; echo -n "$wxdata[3]°"; set_color normal
|
||||
echo -n "|"; set_color -d red; echo -n "$wxdata[4]°"; set_color normal; echo ")"
|
||||
else
|
||||
return 1
|
||||
end
|
||||
end
|
||||
'';
|
||||
|
||||
get-local-ip =
|
||||
"ip addr show $(ip route | grep default | awk '{print $5}') | grep 'inet ' | awk '{print $2}' | cut -d/ -f1";
|
||||
|
|
Loading…
Reference in a new issue