Skip to content

Instantly share code, notes, and snippets.

@ndbroadbent
Last active June 16, 2019 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndbroadbent/a905291557bf38897aecfdf50e9a9413 to your computer and use it in GitHub Desktop.
Save ndbroadbent/a905291557bf38897aecfdf50e9a9413 to your computer and use it in GitHub Desktop.
Notification function for long-running commands
# ~/.bashrc
# Here's a nice alert sound you can use: https://www.dropbox.com/s/ctziqfuqt5q9fek/alert.mp3?dl=0
# Find some more here: https://notificationsounds.com/notification-sounds
alias alert="afplay ~/sounds/alert.mp3"
function n() {
local ALERT="Alert from Bash"
local EXIT_CODE=0
if [ -n "$1" ]; then
"$@"
EXIT_CODE=$?
ALERT="Finished running: $*"
fi
alert
osascript -e "display notification \"$ALERT\""
return "$EXIT_CODE"
}
# Examples:
#
# $ n make
# $ n rspec
#
# $ command && other_command; n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment