Skip to content

Instantly share code, notes, and snippets.

@welbornprod
Last active December 11, 2015 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save welbornprod/4679400 to your computer and use it in GitHub Desktop.
Save welbornprod/4679400 to your computer and use it in GitHub Desktop.
display current weather in your BASH terminal. Uses zip-code to determine current area. Might need to install 'lynx' console browser. ... sudo apt-get install lynx
# BASH function
function weather() {
if [ "${1}" = "" ] ; then
# echo "Usage: weather 90210"
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=90210" | grep -A13 'Latest Observation'
else
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=${1}" | grep -A13 'Latest Observation'
fi
}
# BASH single-line command:
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=[YOUR_ZIP_CODE_HERE]" | grep -A13 'Latest Observation'
# BASH function
function weatherweek()
{
# show weather for the week per zipcode
if [ "${1}" = "" ] ; then
# echo "Usage: weatherweek [Your ZipCode]"
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=90210" | grep -A30 'Forecast Summary'
else
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=${1}" | grep -A30 'Forecast Summary'
fi
}
# BASH single-line command
lynx -dump -nonumbers -width=160 "http://weather.unisys.com/forecast.php?Name=[YOUR_ZIPCODE_HERE]" | grep -A30 'Forecast Summary'
@welbornprod
Copy link
Author

This is part of a series of old-school BASH commands that I picked up a long time ago. The problem was none of those commands worked. The server they connected to had been moved, or changed the format of their pages. So I re-wrote a couple of my favorites, and saved them here for anyone to use. As of today, all of these commands work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment