-
-
Save azrsh/b7755a78253075c22531f88cd4355b7c to your computer and use it in GitHub Desktop.
Notify a command completion
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 | |
$@ | |
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\"" |
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 | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${1}\"}" "${SLACK_WEBHOOK_URL}" |
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 | |
$@ | |
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