Skip to content

Instantly share code, notes, and snippets.

@somewhatabstract
Last active October 31, 2025 22:13
Show Gist options
  • Select an option

  • Save somewhatabstract/fae01eb628c5975f1d551a8ea9b28d40 to your computer and use it in GitHub Desktop.

Select an option

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
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