RESEARCH
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
- 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
Related documents
- 001
- 002
- 003
- 004
research · MD
100 jogos cozy para quem ama Stardew Valley - 005