mirror of
https://github.com/chubin/wttr.in
synced 2024-11-15 00:27:09 +00:00
Merge branch 'master' of https://github.com/chubin/wttr.in
This commit is contained in:
commit
2db9c3345c
2 changed files with 33 additions and 6 deletions
|
@ -1,7 +1,31 @@
|
|||
wttr()
|
||||
{
|
||||
# change Paris to your default location
|
||||
local request="wttr.in/${1-Paris}"
|
||||
[ "$(tput cols)" -lt 125 ] && request+='?n'
|
||||
curl -H "Accept-Language: ${LANG%_*}" --compressed "$request"
|
||||
#! /usr/bin/env bash
|
||||
# If you source this file, it will set WTTR_PARAMS as well as show weather.
|
||||
|
||||
# WTTR_PARAMS is space-separated URL parameters, many of which are single characters that can be
|
||||
# lumped together. For example, "F q m" behaves the same as "Fqm".
|
||||
if [[ -z "$WTTR_PARAMS" ]]; then
|
||||
# Form localized URL parameters for curl
|
||||
if [[ -t 1 ]] && [[ "$(tput cols)" -lt 125 ]]; then
|
||||
WTTR_PARAMS+='n'
|
||||
fi 2> /dev/null
|
||||
for _token in $( locale LC_MEASUREMENT ); do
|
||||
case $_token in
|
||||
1) WTTR_PARAMS+='m' ;;
|
||||
2) WTTR_PARAMS+='u' ;;
|
||||
esac
|
||||
done 2> /dev/null
|
||||
unset _token
|
||||
export WTTR_PARAMS
|
||||
fi
|
||||
|
||||
wttr() {
|
||||
local location="${1// /+}"
|
||||
command shift
|
||||
local args=""
|
||||
for p in $WTTR_PARAMS "$@"; do
|
||||
args+=" --data-urlencode $p "
|
||||
done
|
||||
curl -fGsS -H "Accept-Language: ${LANG%_*}" $args --compressed "wttr.in/${location}"
|
||||
}
|
||||
|
||||
wttr "$@"
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
: Bruine légère : Light drizzle
|
||||
: Chasse-neige basse : Low drifting snow
|
||||
: Pluie et neige légères : Light rain and snow
|
||||
: Averses proches : Shower in vicinity
|
||||
: Pluie et orages : Rain with thunderstorm
|
||||
: Averse de pluie et neige mêlées : Rain and snow shower
|
||||
113 : Temps clair : Clear
|
||||
113 : Ensoleillé : Sunny
|
||||
116 : Partiellement couvert : Partly cloudy
|
||||
|
|
Loading…
Reference in a new issue