Last active
June 16, 2019 19:46
-
-
Save ndbroadbent/a905291557bf38897aecfdf50e9a9413 to your computer and use it in GitHub Desktop.
Notification function for long-running commands
This file contains 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
# ~/.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