-
Notifications
You must be signed in to change notification settings - Fork 6
/
notify
executable file
·47 lines (43 loc) · 1.09 KB
/
notify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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
$@
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
RESULT="SUCCESS"
echo $RESULT
say
else
RESULT="FAILURE"
echo $RESULT
say
exit $EXIT_CODE
fi