Skip to content

Instantly share code, notes, and snippets.

@geovanisouza92
Created October 31, 2014 13:30
Show Gist options
  • Select an option

  • Save geovanisouza92/ead47ea840c828b7feba to your computer and use it in GitHub Desktop.

Select an option

Save geovanisouza92/ead47ea840c828b7feba to your computer and use it in GitHub Desktop.
Send push notifications from shell
#
# 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