- Exit status
- How to use
Weather report written in Bash.
bash-weather gets the computer's public IP address through DynDNS and uses geolocation (http://freegeoip.net/) to acquire its current location which is used to get weather condition and forecast from OpenWeatherMap.
This project is licensed under GNU General Public License Version 3+. For the full license, see
- OpenWeatherMap API key (http://openweathermap.org/appid).
- Bash shell ≥ 4.2.
- A terminal with a size of at least 80×22 (80 columns, 22 rows).
bcbasic calculator for floating point arithmetic. Can be found in the
bcpackage on major Linux distributions.
curlcommand-line tool for getting data using HTTP protocol. cURL can be found in the
curlpackage on major Linux distributions.
grepcommand-line tool used for parsing downloaded XML data.
grepcan be found in the
greppackage on major Linux distributions.
tputfor terminal handling. Can be found in different
ncursespackages on Linux distributions (see the table below for major distros).
4. Exit status
0bash-weather exited successfully.
1Missing necessary programs to run bash-weather, or wrong command-line arguments.
2Too small terminal size (< 80×22).
3Missing OpenWeatherMap API key.
5. How to use
First you have to acquire bash-weather:
git clone https://github.com/szantaii/bash-weather.git
Enter bash-weather's directory:
Add your OpenWeatherMap API key to the end of the
openweathermap.key file, e.g.
# Add your OpenWeatherMap API key below (http://openweathermap.org/appid) 0123dummy456key789
Use the Bash interpreter to start the script:
bash-weather can be started with the following command line options:
-kSpecifies OpenWeatherMap API key from the command-line.
-hPrints a simple help to the screen, and exits.
-t city_nameSets the city for manual weather lookup.
-c country_codeSets the country for manual weather lookup.
-fEnables colored output.
Note: If the OpenWeatherMap API key is specified from the command-line, it will override the API key set in the
Get the current weather in Las Vegas:
bash bash-weather.sh -t "Las Vegas" -c US
Note: don't forget to enclose city names that consist of more than one word within quotes.
Get the current weather in London:
bash bash-weather.sh -t London -c UK
Get the current weather at your current location by specifying the OpenWeatherMap API key from the command-line:
bash bash-weather.sh -k 0123dummy456key789
Get the current weather in Christchurch, New Zealand with colored output:
bash bash-weather.sh -c NZ -t Christchurch -f
Note: the terminal emulator must support 16 colors (e.g. xterm, GNOME Terminal, Konsole); displayed colors may vary in different terminal emulators and by custom profile settings.
If you downloaded, and started bash-weather then you'll see a screen like this:
bash-weather BUDAPEST, HUNGARY _________________ oo ___ __ _ _____ . ** . |__ \ /_ |(_) / ____| *'. ** .'* ) | | | | | '*o. ** .o*' / / | | | | '*' .''. '*' / /_ | | | |____ .'********'. |____| |_| \_____| o************o o**************' wind: 27.7 km/h, SW 'oooooo' **************** 'oooooo' '**************' 3 Day Forecast ____________________ '************' ,o******o, Wed Thu Fri .o*' ** '*o. ___________ ___________ ___________ ,o*' ** '*o, ,o ** o, Clear Sky Cloudy Clear Sky oo min: 13 C 14 C 11 C CLEAR SKY max: 20 C 17 C 18 C Change unit: 'c', Quit: 'q'
Note: bash-weather will refresh the current weather and forecast every minute.
cChanges the measurement unit (Celsius → Fahrenheit, Fahrenheit → Celsius).