Skip to content

Instantly share code, notes, and snippets.

@rnorth
Last active August 3, 2016 00:49
Show Gist options
  • Save rnorth/11121360 to your computer and use it in GitHub Desktop.
Save rnorth/11121360 to your computer and use it in GitHub Desktop.
Boxcar push notification shell script
#!/bin/bash
# Sends a Boxcar push notification through the Boxcar HTTP API
# Usage examples
# $ bc # Just sends a notification with title 'bc'
# $ bc "Done" # Sends a notification with title 'Done'
# $ echo foobar | bc # Sends a notification with title 'bc' and message body 'foobar'
# $ echo foobar | bc "Done" # Sends a notification with title 'Done' and message body 'foobar'
#
# Expects a file ~/.boxcar to exist with content like
# BOXCAR_ACCESS_TOKEN=<your boxcar access token goes here>
. ~/.boxcar
TITLE=${1:-bc}
BOXCAR_SOUND=${BOXCAR_SOUND:-score}
# Only read a message if NOT a tty, e.g. if stdin is piped in
tty -s
if [[ ! $? == 0 ]]; then
read MESSAGE
fi
curl -d "user_credentials=${BOXCAR_ACCESS_TOKEN}" \
-d "notification[title]=${TITLE}" \
-d "notification[long_message]=${MESSAGE}" \
-d "notification[sound]=${BOXCAR_SOUND}" \
https://new.boxcar.io/api/notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment