Ansi Weather 2

Donate using Liberapay

Further to my previous post on ansi weather

I wrote this, which asks for your location, and displays the weather.

echo "where do you live ?"
read location
ansiweather -l $location

In my previous post I was trying to use sed to clean up the output, this isn't needed as the -a option removes the colour coding from the output

ansiweather -a false -l Plymouth, UK >> weatherinfo.txt


Weather in Plymouth => -10 °C – Wind => 1.72 m/s NNW – Humidity => 62 % – Pressure => 1028 hPa

Which is far better.

so our new shell script is

1 #send weather info to Mastodon
  2 # current date
  3 date > weatherinfo.txt
  4 # current weather
  5 # use -a false to remove colour from output, set location, output to a file
  6 ansiweather -a false -l Plymouth, UK >> weatherinfo.txt
  7 # output to console too
  8 ansiweather -a false -l Plymouth, UK
  9 #send to Mastodon
 10 toot post < weatherinfo.txt
 11 # done
 12 echo done

So the final output to Mastodon is

Final Output

There are more options in the file

Thank you to Noisytoot for helping with this.

If you now combine the 2nd script with the one I have at the top of this page you should be able to input your location, then get the local weather.



#YearOfTheFediverse,#ansiweather,#weather,#mastodon,#bash,#console,#terminal #information

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

MastodonPeertubeQoto sign up


Donate using Liberapay