In this article, we will discuss a simple method to check weather forecasts in Windows and Linux terminals.
We will use wttr.in web service to get the weather forecast.
The wttr.in feature includes
- 3 days weather forecast from the current day
- Weather information for specific location, area code
- Automatic location detection based on your IP addresss
- Supports 3 types of output format; ANSI for terminal,HTML for web browsers, or PNG for graphical viewers
- Can display Moon phases
Let’s dive into how we can get weather information in the terminal.
Weather forecast in Linux terminal
First, we need to install curl and run the following command
For Debian based systems
$ sudo apt update $ sudo apt upgrade $ sudo apt install curl
For Fedora users run the following command
$ yum install curl
Run the following command in terminal
$ curl wttr.in
To know the current moon phase run the following command.
$ curl wttr.in/moon
To save weather information as image run the following command.
$ wget wttr.in/Paris.png $ wget wttr.in/India.png
Weather forecast in Windows terminal
We need to use PowerShell in Windows to access the weather service.
We will use the Invoke-RestMethod cmdlet in PowerShell to get the weather forecast from wttr.in. In the searchbar type “powershell” and open it.
Run the following command
Invoke-RestMethod https://wttr.in
We can also run this using the curl command, download curl executables and add it to the path environmental variable.
Conclusion
There you have it, a simple method to check the weather forecasts from Windows/Linux terminal. Hope you enjoyed reading the article.