Last active
January 7, 2016 10:47
-
-
Save taeguk/03ce5836fe8f179168eb to your computer and use it in GitHub Desktop.
Simple pushbullet-bash
This file contains 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
#!/bin/bash | |
if [ $# -lt 3 ] | |
then | |
echo "[Usage] $0 <TITLE> <BODY> <URL>" | |
exit 1 | |
fi | |
ACCESS_TOKEN=`cat access_token | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'` | |
TYPE="link" | |
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') | |
URL=$3 | |
DATA="{\"type\": \"$TYPE\", \"title\": \"$TITLE\", \"body\": \"$BODY\", \"url\": \"$URL\"}" | |
eval "curl --header 'Authorization: Bearer $ACCESS_TOKEN' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '$DATA'" | |
echo |
This file contains 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
#!/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