Hacker News new | comments | ask | show | jobs | submit login

Made a small bash function for it. You can give the city as an argument and otherwise defaults to the env var $WEATHER_CITY and if that's not set, won't provide any city to the site which will result in the site guessing your location.

weather() {

    if [ "$1" ] ; then
        city=$1
    else
        city=$WEATHER_CITY
    fi

    curl http://wttr.in/$city

}



As a quick aside, you can set default variables in bash with ${var-default}, so your function can be condensed to:

  weather()
  {
    curl http://wttr.in/${1-$WEATHER_CITY}
  }




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: