Weather report written in Bash
Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore Updated gitignore. May 21, 2013
LICENSE Added license. May 21, 2013
README.md Updated README Oct 25, 2015
bash-weather.sh Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
change-unit-type.sh Removed unnecessary empty lines. Mar 25, 2014
check-prerequisites.sh Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
clear-help.sh Removed unnecessary empty lines. Mar 25, 2014
create-buffer.sh Removed unnecessary empty lines. Mar 25, 2014
get-day-of-week.sh Removed unnecessary empty lines. Mar 25, 2014
get-geolocation-data.sh Removed unnecessary empty lines. Mar 25, 2014
get-ip.sh Removed unnecessary empty lines. Mar 25, 2014
get-weather-data.sh Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
init.sh Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
main-loop.sh Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
openweathermap.key Add OpenWeatherMap API key support & minor bug fixes Oct 25, 2015
print-ascii-icon.sh Removed unnecessary empty lines. Mar 25, 2014
print-current-temperature.sh Added colored output feature Mar 21, 2015
print-forecast.sh Added colored output feature Mar 21, 2015
print-help.sh Removed unnecessary empty lines. Mar 25, 2014
print-location.sh Removed unnecessary empty lines. Mar 25, 2014
print-status-messages.sh Removed unnecessary empty lines. Mar 25, 2014
print-title.sh Removed unnecessary empty lines. Mar 25, 2014
print-weather-condition.sh Removed unnecessary empty lines. Mar 25, 2014
print-wind.sh Minor bug fix Mar 21, 2015
quit.sh Added colored output feature Mar 21, 2015
read-input.sh Removed unnecessary empty lines. Mar 25, 2014
refresh-screen.sh Removed unnecessary empty lines. Mar 25, 2014

README.md

bash-weather


Contents

  1. About
  2. License
  3. Prerequisites
  4. Exit status
  5. How to use

1. About

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.

2. License

This project is licensed under GNU General Public License Version 3+. For the full license, see LICENSE.

3. Prerequisites

  • 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).
  • bc basic calculator for floating point arithmetic. Can be found in the bc package on major Linux distributions.
  • curl command-line tool for getting data using HTTP protocol. cURL can be found in the curl package on major Linux distributions.
  • grep command-line tool used for parsing downloaded XML data. grep can be found in the grep package on major Linux distributions.
  • tput for terminal handling. Can be found in different ncurses packages 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

4. Exit status

  • 0 bash-weather exited successfully.
  • 1 Missing necessary programs to run bash-weather, or wrong command-line arguments.
  • 2 Too small terminal size (< 80×22).
  • 3 Missing OpenWeatherMap API key.

5. How to use

Get bash-weather

First you have to acquire bash-weather:

git clone https://github.com/szantaii/bash-weather.git

Enter bash-weather's directory:

cd bash-weather

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

Start bash-weather

Use the Bash interpreter to start the script:

bash bash-weather.sh

Command-line options

bash-weather can be started with the following command line options:

  • -k Specifies OpenWeatherMap API key from the command-line.
  • -h Prints a simple help to the screen, and exits.
  • -t city_name Sets the city for manual weather lookup.
  • -c country_code Sets the country for manual weather lookup.
  • -f Enables 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.

Examples

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.

Keyboard functions

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:

  • c Changes the measurement unit (Celsius → Fahrenheit, Fahrenheit → Celsius).
  • q Quits bash-weather.