Linux Mac OS Windows

Weather from the Terminal: How to check whether details from the Command Line in Windows, macOS, Linux, and your Web browser

Screenshot-2022-04-13-at-21.38.35

In this guide, you will learn how to view the weather details from the command line (terminal) using wttr.in utility and curl commands. The wttr.in is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers. You can use this utility to display the weather details of any given location. Since wttr.in is a web-based utility, we don’t need to install it or any other additional utilities. To get the weather, you will have to use the wttr.in and curl either from the command line or from a web browser in no time. You may also follow @igor_chubin for wttr.in updates. Do you use Git on Windows, you may want to see this remediation guide: Git Vulnerability: Git for Windows uninstaller is vulnerable to DLL hijacking when run under the SYSTEM user account.

Curl is a versatile tool that allows you to send and receive data over the network. With wttr.in utility, you can display weather details for the following locations.

Current location,
Particular location,
Geographical location,
Domain name or IP address,
Zip code,
Airport code,
Moon phase and 
Also determin the unit of measurement n some countries etc.

Display weather details of the current location

wttr.in currently supports five output formats:

  • ANSI for the terminal;
  • Plain-text for the terminal and scripts;
  • HTML for the browser;
  • PNG for the graphical viewers;
  • JSON for scripts and APIs;
  • Prometheus metrics for scripts and APIs.

Windows Terminal or Command Prompt

With curl you can transfer data from or to a server. Therefore, you can access the service from a CLI as shown below.

curl wttr.in
curlettr56789

Here is a weather report of my location in Hamburg, Germany! The above command will display the weather details of your current location based on your IP address.

Curlwttr

Mac iTerm

On a Mac device, you can still use the same CURL command as this is pre-installed. macOS is a UNIX 03-compliant operating system certified by The Open Group. It has been since 2007, starting with MAC OS X 10.5.

Screenshot-2022-04-13-at-18.14.51

Get Weather Report via PowerShell

Windows, Linux, or Mac, you can use PowerShell to get the Weather details. Starting with Windows 10, version 1803 or later, CURL is installed by default. Kindly run the same command above or the following command below.

PS /Users/christian> Invoke-RestMethod https://wttr.in
Screenshot-2022-04-13-at-18.18.07

Linux

If you get an error message saying curl command not found when trying to run the weather command, this is because the curl package is not pre-installed on your Ubuntu at the time of writing this piece. You can install it as shown below. This depends upon the Linux distribution you!

Install Curl

Curl is a command-line utility for transferring data from or to a remote server. With curl, you can download or upload data using one of the supported protocols, including HTTP, HTTPS, SCP, SFTP, and FTP. Curl is included in the default Ubuntu 20.04 repositories. The installation is pretty straightforward

sudo apt update
sudo apt install curl

Display weather details of the current location

Run the following command curl wttr.in to get the weather condition in Linux as well.

Check for a specific location

In order to get the weather information for a specific location, you can add the desired location to the URL in your request like this.

$ curl wttr.in/Lagos
$ curl wttr.in/Tokyo

Note: You can also set up hotkey ctrl + w for example in your terminal by editing your shell config file or the .zshrc file and adding the bind-key option.

Get Airport Weather Report

Get a Specific Weather report of an Airport, Use the 3-letter airport codes in order to get the weather information at a certain airport.

$ curl wttr.in/los      # Weather for IATA: los, Murtala Muhammed International Airport, Nigeria
$ curl wttr.in/ham      # Weather for IATA: ham, Hamburg Airport, Germany
Screenshot-2022-04-13-at-22.18.23

Get Weather information for a specific Geographical Location

Let’s say you’d like to get the weather for a geographical location other than a town or city – let’s say an attraction in a city, a mountain name, or some special location. Add the character ~ before the name to look up that special location name before the weather is then retrieved.

$ curl wttr.in/~~Louvre+museum
$ curl wttr.in/~Eiffel+Tower
Screenshot-2022-04-13-at-22.25.00

Web Browser (Chrome etc)

From the browser, just enter the following URL in the browser: https://wttr.in/

Screenshot-2022-04-13-at-21.26.23

Display the phase of the moon

Use any of the following commands to display the phase of the moon. For weather units, Map-view, etc, kindly head to the following URL for more details.

Screenshot-2022-04-13-at-22.45.21

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x