wttr.in/share/bash-function.txt
Alexander Meshcheryakov dce65ed181
Guess user location when running weather ""
Omitting colon makes bash substitute default location only when parameter is absent.
Therefore empty city name propagates to wttr.in and allows it to guess.
2018-12-15 14:21:08 +03:00

8 lines
204 B
Plaintext

wttr()
{
# change Paris to your default location
local request="wttr.in/${1-Paris}"
[ "$COLUMNS" -lt 125 ] && request+='?n'
curl -H "Accept-Language: ${LANG%_*}" --compressed "$request"
}