weather.sh
is a useful bash script that allows you to quickly check the weather forecast for a specific location.
- Retrieves weather data from the weatherapi.com API.
- Supports both Celsius and Fahrenheit temperature units.
- Provides current weather conditions, including temperature, humidity, wind speed, and more.
- Easy to use and customizable.
- Bash shell (version 4 or higher)
- curl command-line tool
- ascii-image-converter (optional, for displaying weather icons)
-
Clone or download the
weather.sh
script to your local machine. -
Open a terminal and navigate to the directory where the script is located.
-
Make the script executable by running the following command:
chmod +x weather.sh
-
Get a free API key from weatherapi.com by signing up for an account.
-
Put the API key in the
.env
file in the same directory as the script, like this:KEY=your_api_key_here
To check the weather for a specific location, simply run the script followed by the desired location as an argument. For example:
./weather.sh "New York"
This will display the weather forecast for New York.
bijoy@BijoyKarPC:/mnt/h/bash-shell/useful-bash-scripts/weather$ ./weather.sh "New York" -m
The temperature in New is 28.3 degrees Celsius
The temperature in New is 82.9 degrees Fahrenheit
The weather in New is Sunny
It feels like 33.6 degrees Celsius
It feels like 92.5 degrees Fahrenheit
: .. :
:.:-==-:.:
:.+%%%%+.:.
.:.+%%%%+.:.
:.:-==-:.:
: .. :
-m
flag: Display more detailed weather information, including humidity, wind speed, and visibility.
-
Check the weather in London using Fahrenheit:
./weather.sh London
-
Display help information:
./weather.sh --help
This project is licensed under the MIT License. See the LICENSE file for more information.