Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius
Last active October 26, 2017 13:56
Show Gist options
  • Save goodevilgenius/6006aa9be296868347c307b977fc18f2 to your computer and use it in GitHub Desktop.
Save goodevilgenius/6006aa9be296868347c307b977fc18f2 to your computer and use it in GitHub Desktop.
[OS X Command-line Notifier] #mac
#!/usr/bin/env bash
args=()
while true; do
if [ "$1" = "-title" -o "$1" = "-t" ]; then
shift
args=( "${args[@]}" with title "\"$1\"" )
shift
elif [ "$1" = "-subtitle" -o "$1" = "-st" ]; then
shift
args=( "${args[@]}" subtitle "\"$1\"" )
shift
elif [ "$1" = "-sound" -o "$1" = "-s" ]; then
shift
args=( "${args[@]}" sound name "\"$1\"" )
shift
else
break
fi
done
args=( display notification "\"$*\"" "${args[@]}" )
osascript -e "${args[*]}"
# Command-line Notifier for OS X
# Add to your $PATH, chmod +x it, and then call it like so:
# notify.sh [-t "Title"] [-st "Subtitle"] [-s "Sound Name"] Text to display in notification
# I've tested it using BASH 4.3 (installed through MacPorts) and 3.2.57 (preinstalled with El Capitan),
# and it worked fine with both
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment