Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius goodevilgenius/notify.sh
Last active Oct 26, 2017

Embed
What would you like to do?
[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
You can’t perform that action at this time.