Handle narrow terminals in sample bash function

Also allow compression of server response
This commit is contained in:
Alexander Meshcheryakov 2018-12-14 00:34:07 +03:00 committed by GitHub
parent f3aca556e7
commit d3b28cbf09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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