Murad Library
RESEARCH#md

RESEARCH

Weather in the terminal with `weather`: Windows and Linux

post_weather_windows_linuxen.md

research·#MD·post_weather_windows_linuxen.md
Date
Reading
2 min read

Weather in the terminal with weather: Windows and Linux

Today we configured a simple command called weather to check the forecast directly from the terminal using wttr.in. It is a console-oriented weather service that works nicely with tools like curl, wget, and httpie, while also supporting HTML and PNG output.

The idea is simple: instead of opening a browser, a heavy website, or another app, you just type:

weather

and the terminal shows the forecast for São Lourenço.

On Windows, with PowerShell

On Windows, we created a function inside the user's PowerShell profile. This profile is a .ps1 file loaded automatically when PowerShell starts.

Open PowerShell and run:

if (!(Test-Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}

notepad $PROFILE

In the file that opens, paste:

function weather {
    curl.exe "https://wttr.in/Sao+Lourenco"
}

Save the file, close PowerShell, and open it again.

Now just type:

weather

On Linux, with Bash

On Linux, we can create an alias in the ~/.bashrc file.

Open the file:

nano ~/.bashrc

At the end of the file, add:

alias weather='curl "https://wttr.in/Sao+Lourenco"'

Save it and reload the shell configuration:

source ~/.bashrc

Now run:

weather

Short forecast version

If you prefer a compact output, useful for scripts or status bars, use this version:

Windows

function weather {
    curl.exe "https://wttr.in/Sao+Lourenco?format=%l:+%c+%t+%w"
}

Linux

alias weather='curl "https://wttr.in/Sao+Lourenco?format=%l:+%c+%t+%w"'

Conclusion

This is a small adjustment that makes the terminal more useful in everyday life. With a single word, weather, both Windows and Linux can show the weather forecast without opening a browser, installing another app, or adding unnecessary complexity.

References

Related documents

Weather in the terminal with `weather`: Windows and Linux · Murad Library