This is a simple Bash script that fetches and displays the current weather for the user's location. The weather data is obtained using the WeatherAPI based on the user's IP address.
- Bash: The script is written in Bash and requires a Unix-like operating system.
- curl: Used to fetch data from the web.
- jq: A lightweight and flexible command-line JSON processor.
-
Clone the Repository:
git clone https://github.com/yourusername/weather-script.git cd weather-script
-
Install Dependencies: Ensure
curl
andjq
are installed on your system. You can install them using the following commands:For Debian-based systems (Ubuntu, etc.):
sudo apt-get update sudo apt-get install curl jq
For Red Hat-based systems (Fedora, CentOS, etc.):
sudo dnf install curl jq
For macOS:
brew install curl jq
-
Set API Key: Obtain an API key from WeatherAPI and set it as an environment variable:
export API_KEY=your_api_key_here
-
Run the Script: Execute the script using the following command:
./weather.sh
-
Output: The script will output the current weather condition along with an appropriate emoji representation. For example:
Hello username, Current weather in CityName: Sunny 🌞
This project is licensed under the MIT License. See the LICENSE
file for details.