Skip to content

Instantly share code, notes, and snippets.

@geoghegan
Created August 15, 2018 09:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoghegan/1da585d6e89bec18b8e0a47fff373a2f to your computer and use it in GitHub Desktop.
Save geoghegan/1da585d6e89bec18b8e0a47fff373a2f to your computer and use it in GitHub Desktop.
Command line weather
###
# Shows your local weather using curl
# Defaults to Dublin, Ireland (DUB) if the Weather server cannot determine your location
# instead of Oymyakon, Russia (coldest place on earth)
###
LOCAL_WEATHER=$(curl -s -N http://wttr.in/?m | head -n 7 | grep "Weather report: Oymyakon, Russia")
if [[ $LOCAL_WEATHER == 'Weather report: Oymyakon, Russia' ]]
then
curl -s -N http://wttr.in/DUB | head -n 7
echo "Could not determine location"
else
curl -s -N http://wttr.in/?m | head -n 7
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment