Periodically syncs the latest entry from Nightscout to an eval-able file,
so that you can include your latest blood glucose entry in your terminal
prompt (also known as the
The trend and target high/low values are also provided, so that you may render arrows and colors as desired:
As a programmer, your
$PS1 is a highly intimate thing which you should take some
time to create a setup that is pleasing to you. After all, you are staring at it
all day. That said, how you use the
nightscout-ps1 variables is up to you!
However, for convenience, the setup from the screenshots above is included here as
well. OK, on to the technical stuff.
The main key is to
~/.bgl-cache file in a function which gets
executed in the
$PS1. The cache file looks something like:
local nightscout_ts="1513457266000"local nightscout_bgl="104"local nightscout_trend="FortyFiveDown"local nightscout_target_top="180"local nightscout_target_bottom="80"local nightscout_mgdl="104"local nightscout_mills="1513457266000"local nightscout_device="share2"local nightscout_direction="FortyFiveDown"local nightscout_scaled="104"
To achieve a setup similar to the screenshots above, include the code below as a
starting point. Typically you define your
$PS1 in your
or other similar files that get executed every time a shell session is started.
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 '')"export PS1="\$(__ps1_bgl) $ "
Remember to customize the
$PS1 further as you like! Restart your shell
source the file again to see the changes in effect.
Setup on MacOS
cp service/io.n8.nightscout-ps1.plist ~/Library/LaunchAgents/launchctl load ~/Library/LaunchAgents/io.n8.nightscout-ps1.plist
Setup on Linux
cp service/nightscout-ps1.service /etc/systemd/system/sudo systemd start nightscout-ps1sudo systemd enable nightscout-ps1
Setup on Windows
TODO: add real docs