Fixing weather grabbing initials for states with two words

This commit is contained in:
Alex Epstein 2017-11-25 12:29:31 -05:00
parent aec1a885ae
commit 98c6210d06
1 changed files with 5 additions and 1 deletions

View File

@ -40,7 +40,11 @@ getIPWeather()
if [[ $country == "US" ]]; then ## if were in the us id rather not use longitude and latitude so the output is nicer
city=$(httpGet ipinfo.io/city) > /dev/null
region=$(httpGet ipinfo.io/region) > /dev/null
region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]")
if [[ $(echo $region | wc -w) == 2 ]];then
region=$(echo $region | grep -Eo "[A-Z]*" | tr -d "[:space:]")
else
region=$(echo "$region" | cut -c "1-2" | tr "[:lower:]" "[:upper:]")
fi
httpGet $locale.wttr.in/$city,$region$1
else ## otherwise we are going to use longitude and latitude
location=$(httpGet ipinfo.io/loc) > /dev/null