Created
January 3, 2018 21:09
-
-
Save terrbear/cefba97301192a162c7d47498d510ccb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ps1_bgl { | |
source ~/.nightscout/info.sh | |
local RED="$(tput setaf 1 2>/dev/null || echo '')" | |
local GREEN="$(tput setaf 2 2>/dev/null || echo '')" | |
local YELLOW="$(tput setaf 3 2>/dev/null || echo '')" | |
local NO_COLOR="$(tput sgr0 2>/dev/null || echo '')" | |
local trend="?" | |
case ${nightscout_trend} in | |
DoubleUp) trend="⇈";; | |
SingleUp) trend="↑";; | |
FortyFiveUp) trend="↗";; | |
Flat) trend="→";; | |
FortyFiveDown) trend="↘";; | |
SingleDown) trend="↓";; | |
DoubleDown) trend="⇊";; | |
esac | |
if [ "${nightscout_bgl}" -ge "180" ]; then | |
printf "\001${YELLOW}\002" | |
elif [ "${nightscout_bgl}" -le "80" ]; then | |
printf "\001${RED}\002" | |
else | |
printf "\001${GREEN}\002" | |
fi | |
printf "%03d %s" "${nightscout_bgl}" "${trend}" | |
printf "\001${NO_COLOR}\002" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p ~/.nightscout | |
curl http://www.mayabetes.org/api/v1/entries.json > ~/.nightscout/current.json | |
rm -f ~/.nightscout/info.sh | |
echo "export nightscout_bgl=$(cat ~/.nightscout/current.json | /usr/local/bin/jq .[0].sgv)" > ~/.nightscout/info.sh | |
echo "export nightscout_trend=$(cat ~/.nightscout/current.json | /usr/local/bin/jq .[0].direction)" >> ~/.nightscout/info.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment