Last active
October 31, 2025 22:13
-
-
Save somewhatabstract/fae01eb628c5975f1d551a8ea9b28d40 to your computer and use it in GitHub Desktop.
Simple bash commands for displaying notifications/alerts on macOS; useful for adding a toast on command completions
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
| notify() { | |
| osascript -e "display notification \"$2\" with title \"$1\" sound name \"${3:-default}\"" | |
| } | |
| alert() { | |
| local background=false | |
| # Check for --background or -b flag | |
| if [[ "$1" == "--background" || "$1" == "-b" ]]; then | |
| background=true | |
| shift | |
| fi | |
| if [[ "$background" == true ]]; then | |
| # If running in the background, just suppress the console output. | |
| ("$@" &>/dev/null && notify "✅ Success!" "$(echo "$@")" Blow || notify "⚠️ Oh noes!" "$(echo "$@")" Sosumi) & | |
| else | |
| "$@" && notify "✅ Success!" "$(echo "$@")" Blow || notify "⚠️ Oh noes!" "$(echo "$@")" Sosumi | |
| fi | |
| } | |
| alias 🚨=alert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment