+# retrieve weather information on the console
+# Usage example: 'weather LOWG'
+ weather () {
+ [ -n "$1" ] || {
+ print 'Usage: weather <station_id>' >&2
+ return 1
+ }
+
+ local PLACE="${1:u}"
+ local FILE="$HOME/.weather/$PLACE"
+ local LOG="$HOME/.weather/log"
+
+ [ -d $HOME/.weather ] || {
+ print -n "Creating $HOME/.weather: "
+ mkdir $HOME/.weather
+ print 'done'
+ }
+
+ print "Retrieving information for ${PLACE}:"
+ print
+ wget -T 10 --no-verbose --output-file=$LOG --output-document=$FILE --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT
+
+ if [[ $? = 0 ]] ; then
+ if [ -n "$VERBOSE" ] ; then
+ cat $FILE
+ else
+ DATE=$(grep 'UTC' $FILE | sed 's#.* /##')
+ TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' $FILE| tr -d '(')
+ echo "date: $DATE"
+ echo "temp: $TEMPERATURE"
+ fi
+ else
+ print "There was an error retrieving the weather information for $PLACE" >&2
+ cat $LOG
+ return 1
+ fi
+ }
+
+