#!/usr/bin/env bash # Author: Lilian BESSON, (C) 2018-oo # Email: Lilian.BESSON[AT]ens-cachan[DOT]fr # Date: 11-05-2018. # Web: https://bitbucket.org/lbesson/bin/src/master/wttr # # A bash script to get nice colored weather forecast in your terminal. # Usage: # $ wttr # default to asking http://ipinfo.io for the city # $ wttr "Avignon, France" # # Adapted from https://github.com/chubin/wttr.in # Source: curl wttr.in/:bash.function # # License: MIT Licence (http://lbesson.mit-license.org). # First, try to guess the city city="Rennes, France" # Inspired by https://github.com/niklasberglund/ipinfo url="http://ipinfo.io/city" the_info=$(curl -s $url) city=$(echo "$the_info" | sed -e '/[{}]/d' | sed 's/\"//g' | sed 's/ //g' | sed 's/,$//') city="${*:-$city}" # Then, get the weather curl --silent -H "Accept-Language: ${LANG%_*}" wttr.in/"${city}" | head -n-3