[Tutorial] ASCII Weather

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
User avatar
Phillski
Posts: 37
Joined: Fri Feb 02, 2018 10:52 am

[Tutorial] ASCII Weather

Post by Phillski »

I'm sure at some point we have all wanted to know what the weather forecast is but did not want to leave the safety of our SSH session. Well, now you can with a simple command.

Just enter this into your command line to install.

This version is now obsolete (still works just fine but is only supports 2 column output)

Code: Select all

echo -e "\nfunction weather() { curl wttr.in/\$@?2n; }" >> ~/.bashrc
source ~/.bashrc

New Version that will return an expanded weather report if your session is wide enough (and incorporates WarHawks suggestion).

Code: Select all

echo -e "\nfunction weather()\n{\nif [ \$COLUMNS -lt 125 ]\nthen\n  curl wttr.in/\$@?2n\nelse\n  curl wttr.in/\$@\nfi\n}" >> ~/.bashrc && source ~/.bashrc

To use just type 'weather' at the prompt and you will get the weather forecast for your current IP based location:
Weather1.png
Weather1.png (14.64 KiB) Viewed 3930 times
Scrolling up gets you this:
Weather2.png
Weather2.png (10.3 KiB) Viewed 3930 times
Should you wish to get the weather report for a different location ... well, you can do that too!
Here's the output for 'weather NewYork':
Weather3.png
Weather3.png (13.64 KiB) Viewed 3930 times
Weather4.png
Weather4.png (12.08 KiB) Viewed 3930 times
If you're running a session that is nice and wide it will (now) return an expanded weather report.
In this example columns=132 and rows=43:
Weather5.png
Last edited by Phillski on Sun Feb 04, 2018 5:12 am, edited 1 time in total.
User avatar
WarHawk
Posts: 730
Joined: Thu Jul 20, 2017 8:55 am

Re: [Tutorial] ASCII Weather

Post by WarHawk »

Oh that is SO COOL!!!!

Honestly...developers...you should make this part of the build!

Very neat!!!!

I go thru my .bashrc and make the alias's a bit different
alias ll='ls -lah'

this way to get a full directory listing...i just type ll also uncommented the color stuff so my command prompts and stuff are color

Very awesome!!! Thanks for this!

oh you can make that command all one line too

Code: Select all

echo -e "\nfunction weather() { curl wttr.in/\$@?2n; }" >> ~/.bashrc && source ~/.bashrc
User avatar
Phillski
Posts: 37
Joined: Fri Feb 02, 2018 10:52 am

Re: [Tutorial] ASCII Weather

Post by Phillski »

Glad you like it, just for fun you can even check the weather on the moon :)

The world needs more fun ASCII stuff.
billouetaudrey
Posts: 16
Joined: Sun Nov 22, 2020 10:38 am

Re: [Tutorial] ASCII Weather

Post by billouetaudrey »

Hi,

Where can I change default location please ?
User avatar
Phillski
Posts: 37
Joined: Fri Feb 02, 2018 10:52 am

Re: [Tutorial] ASCII Weather

Post by Phillski »

There is no default location as such as it it worked out from your IP address, you can specify the location by typing 'weather CityName' (e.g. 'weather Moscow')
Post Reply