Fish shell welcome message showing weather conditions
For some reason, I always want to know the weather conditions. I barely go outdoors, but I still like to know what’s happening. I have a few shell scripts that kick out some version of the weather. Here’s the one I use most:
#!/bin/sh # Jack Baty, 2023 (https://baty.net) # Grab and parse weather info using WeatherAPI.com jq=/opt/homebrew/bin/jq # Save the response to temporary file # TODO: shouldn't this just be a variable or something instead? weatherfile=`mktemp` curl -s "https://api.weatherapi.com/v1/forecast.json?key=[SNIP]&q=49301&days=1&aqi=no&alerts=no" > $weatherfile now=`${jq} -r .current.condition.text ${weatherfile}` temp=`${jq} -r .current.temp_f ${weatherfile}` condition=`${jq} -r .forecast.forecastday[0].day.condition.text ${weatherfile}` high=`${jq} -r .forecast.forecastday[0].day.maxtemp_f ${weatherfile}` low=`${jq} -r .forecast.forecastday[0].day.mintemp_f ${weatherfile}` echo "${now} ${temp} | Low ${low}, High ${high}" Right now, this returns: Light snow 21.9 | Low 20.1, High 26.4
...