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:
1weather
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:
1if (!(Test-Path $PROFILE)) {
2 New-Item -ItemType File -Path $PROFILE -Force
3}
4
5notepad $PROFILE
In the file that opens, paste:
1function weather {
2 curl.exe "https://wttr.in/Sao+Lourenco"
3}
Save the file, close PowerShell, and open it again.
Now just type:
1weather
On Linux, with Bash #
On Linux, we can create an alias in the ~/.bashrc file.
Open the file:
1nano ~/.bashrc
At the end of the file, add:
1alias weather='curl "https://wttr.in/Sao+Lourenco"'
Save it and reload the shell configuration:
1source ~/.bashrc
Now run:
1weather
Short forecast version #
If you prefer a compact output, useful for scripts or status bars, use this version:
Windows #
1function weather {
2 curl.exe "https://wttr.in/Sao+Lourenco?format=%l:+%c+%t+%w"
3}
Linux #
1alias 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 #
- wttr.in on GitHub: https://github.com/chubin/wttr.in
- Official wttr.in help: https://wttr.in/:help
- PowerShell profiles: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_profiles
- Bash aliases: https://www.gnu.org/software/bash/manual/html_node/Aliases.html