Skip to content

Instantly share code, notes, and snippets.

@natebunnyfield
Created May 14, 2012 04:11
Show Gist options
  • Save natebunnyfield/2691758 to your computer and use it in GitHub Desktop.
Save natebunnyfield/2691758 to your computer and use it in GitHub Desktop.
weather to unicode
#!/bin/sh
([ $(date +%k) -lt 7 ] || [ $(date +%k) -gt 19 ]) && co=⚪ || co=☀
symbolize=" sed \
-e 's/ inch.*igher.*/↑/i' \
-e 's/ \(inch\|hPa\).*ower.*/↓/i' \
-e 's/overcast/☁☁/i' \
-e 's/partly cloudy/$co☁/i' \
-e 's/mostly cloudy/☁$co/i' \
-e 's/mostly sunny/☀☁/i' \
-e 's/partly sunny/☁☀/i' \
-e 's/mostly clear/ $co/i' \
-e 's/sunny/ ☀/i' \
-e 's/cloudy/☁/i' \
-e 's/clear/ $co/i' \
-e 's/rain/☂/i' \
-e 's/thunderstorms\?/⚡☁/i' \
-e 's/showers/☂/i' \
-e 's/snow/☃/i' \
-e 's/rising rapidly/ ⇈/i' \
-e 's/falling rapidly/ ⇊/i' \
"
args="--headers=temperature,sky_conditions,pressure_tendency | $symbolize | sed \
-e 's/[0-9].[0-9][0-9]/ & /i' \
-e 's/^.*\(:\|UTC\)//g' \
-e 's/^Curre.* (.//' \
-e 's/)//' \
-e 's/\(\.[0-9]\)\? [CF].*/°/g' \
-e 's/current conditions at .//i' \
| tr -d '\n' | /usr/local/bin/titlecase | tr '[:lower:]' '[:upper:]'"
remote() {
eval weather -i KDCA $args &
eval weather -i KIAD $args &
#eval weather -i EIDW $args | sed 's/IDW/DUB/' &
#eval weather -i EICK $args | sed 's/ICK/ORK/' &
#eval weather -i EINN $args | sed 's/INN/SNN/' &
eval weather MDW $args &
eval weather ORD $args &
#eval weather -i KSGF $args &
#eval weather -i KBBG $args &
#eval weather -i KQTZ $args | sed 's/QTZ/BGW/' &
eval weather -i NZSP $args | sed 's/ZSP/Z /' &
#eval weather -i YPPH $args &
#eval weather -i KPDX $args &
#eval weather -i TISX $args &
#eval weather -i BIRK $args &
}
remote | sort -rk2
echo
local() {
eval weather -i KLWC $args &
eval weather MCI $args &
eval weather -i KMKC $args &
}
local | sort -rk2
echo
eval "weather --flines=12 -n -f | /usr/local/bin/titlecase | $symbolize | sed \
-e 's/\.\?\.\?\./ /g' \
-e '/^Zone/d' \
-e '/^Zfp/d' \
-e 's/s around//' \
-e 's/s in the//' \
-e 's/$/ …/' \
-e 's/\(with\)\? a \([0-9]*\) percent chance of/ \2%/i' \
-e 's/Sunday/Sun/i' \
-e 's/Monday/Mon/i' \
-e 's/Tuesday/Tue/i' \
-e 's/Wednesday/Wed/i' \
-e 's/Thursday/Thu/i' \
-e 's/Friday/Fri/i' \
-e 's/Saturday/Sat/i' \
-e 's/Lower //i' \
-e 's/Upper //i' \
-e 's/Mid //i' \
-e 's/High/ /i' \
-e 's/Low/\\//i' \
-e 's/\(North\|South\|East\|West\).*//i' \
-e 's/a chance of //i' \
-e 's/and //i' \
-e 's/in //i' \
-e 's/the //i' \
-e 's/likely //i' \
-e 's/mainly //i' \
-e 's/becoming //i' \
-e 's/with //i' \
-e 's/a chance //i' \
| /usr/local/bin/titlecase | sed \
-e 's/Today/ /i' \
-e 's/This .*/ /i' \
-e 's/Tonight/ /i' \
-e 's/... night/ /i' \
-e 's/evening//i' \
-e 's/ then/,/i' \
-e 's/ …/…/'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment