Created
August 15, 2018 09:52
-
-
Save geoghegan/1da585d6e89bec18b8e0a47fff373a2f to your computer and use it in GitHub Desktop.
Command line weather
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# 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