Skip to content

Instantly share code, notes, and snippets.

@azrsh
Last active August 31, 2023 08:15
Show Gist options
  • Save azrsh/b7755a78253075c22531f88cd4355b7c to your computer and use it in GitHub Desktop.
Save azrsh/b7755a78253075c22531f88cd4355b7c to your computer and use it in GitHub Desktop.
Notify a command completion
#!/bin/bash
$@
EXIT_CODE=${?}
if [ ${EXIT_CODE} = 0 ]; then
MESSAGE="✅ \`${@}\` terminated with exit code ${EXIT_CODE}"
else
MESSAGE="🚨 \`${@}\` terminated with exit code ${EXIT_CODE}"
fi
/usr/bin/osascript -e "display notification \"${MESSAGE}\" with title \"Noti\" sound name \"Submarine\""
#!/bin/bash
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${1}\"}" "${SLACK_WEBHOOK_URL}"
#!/bin/bash
$@
EXIT_CODE=${?}
if [ ${EXIT_CODE} = 0 ]; then
MESSAGE="{\"text\":\":white_check_mark: \`$(whoami)@$(hostname)\$ ${@}\` terminated with exit code \`${EXIT_CODE}\`\"}"
else
MESSAGE="{\"text\":\":rotating_light: \`$(whoami)@$(hostname)\$ ${@}\` terminated with exit code \`${EXIT_CODE}\`\"}"
fi
curl -X POST -H 'Content-type: application/json' --data "${MESSAGE}" "${SLACK_WEBHOOK_URL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment