blob: ab10e4e8e68330eabdbbe865796fbc03d3937dc5 (
plain)
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
|
#!/bin/bash
#
# Shows macOS desktop notifications when a command completes.
# Depending on exit status of the command, a different notification message is shown.
#
# Examples:
# misc/nofify make -j 8 >/dev/null
# Make all font styles in all formats without printing detailed messages
#
# misc/notify make Regular
# Make the regular style in all formats
#
HAS_NOTIFIER=true
if ! (which terminal-notifier >/dev/null); then
HAS_NOTIFIER=false
echo "$0: terminal-notifier not found in PATH (will not notify)" >&2
echo "$0: You can install through: brew install terminal-notifier"
fi
CMDS="$@"
"$@"
STATUS=$?
if $HAS_NOTIFIER; then
if [[ $STATUS -eq 0 ]]; then
terminal-notifier \
-title "$1 ✅" \
-message "$CMDS" \
-activate com.apple.Terminal \
-timeout 8 >/dev/null &
else
terminal-notifier \
-title "$1 failed ❌" \
-message "$CMDS => $STATUS" \
-activate com.apple.Terminal \
-timeout 20 >/dev/null &
fi
fi
exit $STATUS
|