michael@slashetc:~$

Get Weather Information From A Terminal Using Nothing But cURL

wttr.in is a web frontent for Wego, a weather app for the terminal. Using nothing but cURL and wttr.in, you can get weather information from a terminal, without having to install anything (well, except for cURL).

By default, the service tries to determine your location automatically but if that fails, it allows you to specify the location in multiple ways, by city name, 3-letter airport code, ZIP code and it even allows retrieving the weather for the location of a domain name or IP address.
Other features include a 3-day weather forecast, display moon phase and support for both metric (SI; used by default everywhere except the US) and USCS (used by default in the US).
Under the hood, wttr.in uses WorldWeatherOnline for the weather information, though this might change in the future because Wego, the tool which wttr.in uses as its backend, recently switched to forecast.io by default.
While it's not required to install wttr.in to use it, you can install it on your server if you want - see the installation instructions HERE.
wttr.in: online service | source (GitHub)

Using wttr.in

The only requirement for using wttr.in is "curl". Ubuntu / Debian / Linux Mint users (and derivatives) can install it using the following command:
sudo apt-get install curl

Then simply run the command below to get the weather for your current location:
curl wttr.in

If wttr.in fails to detect your current location or if you want to get weather information for a different location, you can specify 3-letter airport codes, city names, domain names or IP addresses. Here are a few examples:

- get the weather for New York (for city names containing spaces, you can either enter the name in quotes or use an underscore - for example, both "new york" and new_york work):

curl wttr.in/"new york"

- get the weather for Paris:

curl wttr.in/paris

- get the weather for London using a 3-letter airport code (I'm using the Heathrow Airport code below):

curl wttr.in/lhr

- get weather information using a ZIP code (note that wttr.in calls this "area code" but area codes are actually a different thing):

curl wttr.in/60602

To retrieve the weather using metric or USCS units, simply append "?m" or "?u" to the command (without the quotes). For instance, to force metric (SI) units to get weather information for Chicago, you would use:
curl wttr.in/chicago?m

To see all the available options, use "curl wttr.in/:help". Here's how it looks like:
$ curl wttr.in/:help
Usage:

$ curl wttr.in # current location
$ curl wttr.in/muc # weather in the Munic airport

Supported location types:

/paris # city name
/muc # airport code (3 letters)
/@stackoverflow.com # domain name
/94107 # area codes

Special locations:

/moon # Moon phase (add ,+US or ,+France for these
cities)

Units:

?m # metric (SI) (used by default everywhere
except US)
?u # USCS (used by default in US)

Special URLs:

/:help # show this page

Tip: add a wattr.io alias for your current location

From what I've read, it looks like wttr.io fails to get the location pretty often so to make it easy to use, you can add an alias to your ~/.bashrc file so you can simply type "wttr" to get the weather for your location.

To add an wttr.io alias for your current location, open ~/.bashrc with a text editor - I'll use Gedit below:

gedit ~/.bashrc

and at the end of the file, paste this:

alias wttr='curl wttr.in/CITY_NAME'
... replace "CITY_NAME" with your city name (or another way supported by wttr.in for getting your location - ZIP code, airpode code, etc. - see above), then save the file and run the following command in a terminal to source the ~/.bashrc file (use its new configuration):
. ~/.bashrc

(there's a dot, then a space before ~/.bashrc)

After you're done, you can simply type "wttr" in a terminal to check the weather.

Originally published at WebUpd8: Daily Ubuntu / Linux news and application reviews.

</div>

</div>