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 LICENSE.
- 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 thebcpackage on major Linux distributions.curlcommand-line tool for getting data using HTTP protocol. cURL can be found in thecurlpackage on major Linux distributions.grepcommand-line tool used for parsing downloaded XML data.grepcan be found in thegreppackage on major Linux distributions.tputfor terminal handling. Can be found in differentncursespackages on Linux distributions (see the table below for major distros).
| Distrbution | Package name |
|---|---|
| Arch Linux | ncurses |
| Debian | ncurses-bin |
| Fedora | ncurses |
| openSUSE | ncurses-utils |
| Ubuntu | ncurses-bin |
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.
First you have to acquire bash-weather:
git clone https://github.com/szantaii/bash-weather.gitEnter bash-weather's directory:
cd bash-weatherAdd 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 bash-weather.shbash-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 openweathermap.key file.
Get the current weather in Las Vegas:
bash bash-weather.sh -t "Las Vegas" -c USNote: 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 UKGet the current weather at your current location by specifying the OpenWeatherMap API key from the command-line:
bash bash-weather.sh -k 0123dummy456key789Get the current weather in Christchurch, New Zealand with colored output:
bash bash-weather.sh -c NZ -t Christchurch -fNote: 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.
Keyboard functions:
cChanges the measurement unit (Celsius → Fahrenheit, Fahrenheit → Celsius).qQuits bash-weather.