Check the Weather

wttr.in

The right way to check the weather

https://wttr.in/

https://wttr.in/montreal

$ curl wttr.in
$ curl wttr.in/Beijing
$ curl wttr.in/Beijing?format=1
$ curl wttr.in/Beijing?format=3
$ curl wttr.in/Beijing?lang=zh
$ curl wttr.in/London
$ curl wttr.in/Moscow
$ curl wttr.in/Salt+Lake+City
$ curl wttr.in/muc      # Weather for IATA: muc, Munich International Airport, Germany
$ curl wttr.in/ham      # Weather for IATA: ham, Hamburg Airport, Germany
$ curl wttr.in/~Vostok+Station
$ curl wttr.in/~Eiffel+Tower
$ curl wttr.in/~Kilimanjaro
$ curl wttr.in/Amsterdam?u  # USCS (used by default in US)
$ curl wttr.in/Amsterdam?m  # metric (SI) (used by default everywhere except US)
$ curl wttr.in/Amsterdam?M  # metric (SI), but show wind speed in m/s

You can add the following command to your .bashrc or .zshrc file to automatically display the weather each time you open the terminal:

echo "Today's weather:"
curl -s wttr.in/?format=3

Integrate weather information in scripts to facilitate automated tasks.

#!/bin/bash
WEATHER=$(curl -s wttr.in?format="%C")
if [[ $WEATHER == *Rain* ]]; then
  echo "It may rain today, remember to bring an umbrella!"
else
  echo "It's a nice day!"
fi
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus