Skip to content

Instantly share code, notes, and snippets.

@emmanuelbernard
Created March 26, 2015 09:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmanuelbernard/153c15f4fa6e0d809f82 to your computer and use it in GitHub Desktop.
Save emmanuelbernard/153c15f4fa6e0d809f82 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Notify you when a task is done
#
# $ notify mvn clean install
# runs 'mvn clean install'
# notify you when it's done
#
# A notification is sent upon build completion if your OS supports it:
# - on Mac OS, install Growl and grownnotifier
# - on Linux, install send-notify
#
# Released under the WTFPL license version 2 http://sam.zoy.org/wtfpl/
#
# Copyright (c) 2010 David Gageot
# Copyright (c) 2011 Sanne Grinovero
# Copyright (c) 2010-2015 Emmanuel Bernard
say() {
if [ `uname -s` == "Darwin" ]; then
# On Mac OS, notify via Growl
which -s growlnotify && growlnotify --name "Command line" --sticky --message "'$CMD_DISPLAY' has finished - $RESULT"
fi
if [ `uname -s` == "Linux" ]; then
# On Linux, notify via notify-send
which notify-send && notify-send "'$CMD_DISPLAY' has finished" "$RESULT"
fi
}
if [[ $# -eq 0 ]]; then
echo "Usage notify <command to run>"
else
CMD_DISPLAY="$@"
fi
$@
if [ $? -eq 0 ]; then
RESULT="SUCCESS"
echo $RESULT
say
else
RESULT="FAILURE"
echo $RESULT
say
exit $?
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment