Skip to content

Instantly share code, notes, and snippets.

@natebunnyfield
Created February 5, 2010 23:59
Show Gist options
  • Save natebunnyfield/296402 to your computer and use it in GitHub Desktop.
Save natebunnyfield/296402 to your computer and use it in GitHub Desktop.
#!/bin/sh
function strip_tags {
sed "s/<[^>][^>]*>//g; s/^ *//g"
}
function break_every_third_line {
awk '{ if ( NR % 3 == 0 || NR == 1 ) print "" } { print }'
}
function sentencecase {
gsed "s/\([^.]\s\)\([A-Z]\)/\1\l\2/g"
}
function strip_wind_info {
sed "s/[A-Z][^.]*mph[^.]*\.//g"
}
function prettify {
break_every_third_line | strip_tags | sentencecase
}
function wunderground {
URL="http://www.wunderground.com/cgi-bin/findweather/getForecast?query=66046";
curl -s $URL | grep "forecast to be" | prettify
}
function wund {
URL="http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=66046";
curl -s $URL | grep "title\|fcttext" | prettify | strip_wind_info
}
wunderground && wund &
wunderground|say && wund|say
sleep .7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment