/nightscout-ps1

Renders your latest blood glucose reading from Nightscout in the command line

Primary LanguageJavaScriptMIT LicenseMIT

nightscout-ps1

Build Status

Syncs the latest two entries from Nightscout to a file the can be consumed by your command line prompt (a.k.a. $PS1).

Installation

Preferred installation is by downloading a pre-compiled binary for your platform:

If there is no binary for your platform, or you would simply like to install from source, you may install from the npm registry:

$ npm install -g nightscout-ps1

Usage

The flags for usage of nightscout-ps1 are listed here, however it is highly recommended that you set up the daemon as a "service" for your operating system.

$ nightscout-ps1 -n "my-nightscout-url.com" -c ~/.nightscout-ps1.env

Replace my-nightscout-url.com with the actual URL to your own Nightscout deployment.

Flag Description
--cache-file/-c Path to write the latest reading file.
Must end in .env or .json, and may be specified more than once.
Defaults to ~/.nightscout-ps1.env.
--nightscout/-n URL of your Nightscout deployment.

Setup on macOS

cp service/io.n8.nightscout-ps1.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/io.n8.nightscout-ps1.plist

Then see Configuring your PS1 below.

Setup on Linux

cp service/nightscout-ps1.service /etc/systemd/system/
sudo systemd start nightscout-ps1
sudo systemd enable nightscout-ps1

Then see Configuring your PS1 below.

Setup on Windows

Check out this blog post by Scott Hanselman to setup as a Windows Service:

Visualizing your real-time blood sugar values AND a Git Prompt on Windows PowerShell and Linux Bash

Configuring your PS1

First, install import.

Second, add the following to your .bashrc file:

. "$(which import)"
import "tootallnate/nightscout-ps1@3.1.0"

export PS1="\$(nightscout_ps1) \$ "

Be sure to add further customizations to your PS1 to your liking!

Formats

The --cache-file/-c flag determines how to format the output file based on the file extension. These are the supported format types:

.env

Formatted with key=value pairs that may be source or eval'd in a shell script (i.e. your .bashrc file). Example.

.json

Formatted as a JSON file, which may consumed by jq or other related tools. Example.