4 ms·
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
by gitaarik 11y ago
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
}
- Tiksi 11y agoAs 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} }