Created
October 31, 2014 13:30
-
-
Save geovanisouza92/ead47ea840c828b7feba to your computer and use it in GitHub Desktop.
Send push notifications from shell
This file contains hidden or 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
| # | |
| # Send push notifications from shell, like this: | |
| # | |
| # $ push Your message here | |
| # $ echo 'Lorem ipsum or another awesome command' | push | |
| # $ docker pull image/tag && push 'Image image/tag download done' | |
| # | |
| # Append the following lines in your ~/.bashrc and set your PUSHBULLET_APIKEY | |
| # To update current bash session, run | |
| # $ . ~/.bashrc | |
| # | |
| # Tested on Ubuntu Trusty 14.04 | |
| # | |
| PUSHBULLET_APIKEY=<your pushbullet api key, found at https://www.pushbullet.com/account> | |
| function push() { | |
| if [[ -z $1 ]]; then | |
| while read content; do | |
| curl -s -u $PUSHBULLET_APIKEY: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary "{\"type\":\"note\",\"title\":\"$content\"}" > /dev/null 2> /dev/null | |
| done | |
| else | |
| curl -s -u $PUSHBULLET_APIKEY: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary "{\"type\":\"note\",\"title\":\"$(echo $@)\"}" > /dev/null 2> /dev/null | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment