Created
February 5, 2019 20:03
-
-
Save shanselman/8f3dac3171fc4b9bcde334d3cdc99d3b to your computer and use it in GitHub Desktop.
nightscout bash profile
This file contains hidden or 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
RED="$(tput setaf 1 2>/dev/null || echo '')" | |
GREEN="$(tput setaf 2 2>/dev/null || echo '')" | |
YELLOW="$(tput setaf 3 2>/dev/null || echo '')" | |
NO_COLOR="$(tput sgr0 2>/dev/null || echo '')" | |
function __ps1_bgl { | |
eval "$(cat /mnt/c/Users/scott/.bgl-cache)" | |
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 "${nightscout_target_top}" ]; then | |
printf "\001${YELLOW}\002" | |
elif [ "${nightscout_bgl}" -le "${nightscout_target_bottom}" ]; then | |
printf "\001${RED}\002" | |
else | |
printf "\001${GREEN}\002" | |
fi | |
printf "%03d %s" "${nightscout_bgl}" "${trend}" | |
printf "\001${NO_COLOR}\002" | |
} | |
export PS1="\$(__ps1_bgl) $ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment