Skip to content

Instantly share code, notes, and snippets.

@taeguk
Last active January 7, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taeguk/03ce5836fe8f179168eb to your computer and use it in GitHub Desktop.
Save taeguk/03ce5836fe8f179168eb to your computer and use it in GitHub Desktop.
Simple pushbullet-bash
#!/bin/bash
if [ $# -lt 2 ]
then
echo "[Usage] $0 <TITLE> <BODY>"
exit 1
fi
ACCESS_TOKEN=`cat access_token | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
TYPE="note"
TITLE=$(echo "$1" | sed 's/\\/\\\\/g' | sed ':a;N;$!ba;s/\n/\\n/g')
BODY=$(echo "$2" | sed 's/\\/\\\\/g' | sed ':a;N;$!ba;s/\n/\\n/g')
DATA="{\"type\": \"$TYPE\", \"title\": \"$TITLE\", \"body\": \"$BODY\"}"
eval "curl --header 'Authorization: Bearer $ACCESS_TOKEN' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '$DATA'"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment