Skip to content

Instantly share code, notes, and snippets.

@sverrejoh
Created May 6, 2020 15:34
Show Gist options
  • Select an option

  • Save sverrejoh/bc61211c8445a20917fc1464c2b282d2 to your computer and use it in GitHub Desktop.

Select an option

Save sverrejoh/bc61211c8445a20917fc1464c2b282d2 to your computer and use it in GitHub Desktop.
Function for sending a notification from shell
function tellme() {
# The success value from the previous command (have to keep it or
# it'll be overwritten by the equation below)
local previous=$?
local statusMessage
[[ $previous -eq 0 ]] \
&& statusMessage="Success" \
|| statusMessage="Failure"
# Prefix message with status
message="$statusMessage: $@";
# Say the result to the speaker and ...
say $message
# Send a notification to my phone.
local token=INSERT_YOUR_TOKEN
local user=INSERT_YOUR_USER
curl -s \
-F "token=$token" \
-F "user=$user" \
-F "title=$statusMessage" \
-F "message=$message" \
https://api.pushover.net/1/messages.json
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment