Advertisement

How to Get Weather Forecast In Linux Console

For various desktop environments like Cinnamon, KDE, MATE, etc there are plenty of desklets, panel applets and widgets to bring you a weather forecast with a fancy look. If you prefer a minimalistic but effective environment, you might be interested in learning how to get weather information right in your terminal emulator or in a pure console environment. Here is how it can be done.

Advertisеment


Before proceeding, ensure that you have the console tool curl installed. In most Linux distros, it is installed out-of-the-box. You can check if it is installed with the following command.
which curl

The command will return the full path to the CURL binary.

Which Curl Linux

Now, we will use an open source web service wttr.in to fetch the weather forecast.

To Get Weather Forecast In Linux Console, execute the following command:

curl wttr.in/LOCATION

Replace the location portion with the name of your place. For example:

curl wttr.in/New-York
curl wttr.in/Bangalore

Linux Weather Forecast In Console

Linux Weather Forecast In Console 2

You can specify the country where you live when required. The syntax is as follows:

curl wttr.in/Madrid,Spain

Linux Weather Forecast In Console LocationNote: It is important to not enter a space between and after the comma. If you add a space after the comma, the service will try to recognize the input parameter as multiple locations. You can use this feature to retrieve forecasts for several locations at once.

For example:

curl wttr.in/Madrid,\ Bangalore

This will show the weather in Madrid and Bangalore.

Alternatively, you can use the plus sign to fetch the forecast for multiple locations:

curl wttr.in/Madrid+Bangalore

If you execute curl without any location specified, the service will try to guess your location based on your IP geolocation information. The command in this case will look as follows:

curl wttr.in

The wttr.in service can show the forecast right in your web browser. Point your browser to the same location you use in curl. See the following screenshot:Linux Weather Forecast In Browser

The service supports a number of options. Open the following page to learn about them:
http://wttr.in/:help

Alternatively, you can use this command in your terminal:

curl http://wttr.in/:help

Here are some useful options.

curl wttr.in/New-York?n

This will display the short version of the forecast which includes only Noon and Night.

curl wttr.in/New-York?0

This will show only the current weather in the specified location.Linux Weather Current

If you add ".png" to the location, the service will return a PNG image. You can embed it in your web page.
For example, open this link: http://wttr.in/New-York.png

Linux Weather Forecast As Png

When in PNG mode, you can pass parameters as follows:

wttr.in/Location_parameters.png

For example:

wttr.in/New-York_tq0.png

The service is localized into several languages.
To change the forecast language, you can use the following syntax:

curl wttr.in/Berlin?lang=de
curl wttr.in/Berlin?lang=ru

Alternatively, you can use subdomains as follows:

curl de.wttr.in/Berlin

curl ru.wttr.in/Moscow

Supported languages are:

az bg ca cs cy da de el eo es fi fr hi hr hu is it ja ko mk ml nl nn pt pl ro ru sk sl sr sr-lat sv tr uk uz vi zh et hy jv ka kk ky lt lv sw th zu bs be

wttr.in can be used not only to check the weather, but also for some other purposes. To see the current Moon phase.

$ curl wttr.in/Moon

Moon Phase

To see the Moon phase for the specified date (2016-12-25), run the following command.

$ curl wttr.in/Moon@2016-12-25

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

One thought on “How to Get Weather Forecast In Linux Console”

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.