diff options
author | Rasmus Andersson <rasmus@notion.se> | 2017-08-22 10:05:20 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2017-08-22 12:23:08 +0300 |
commit | 3b1fffade1473f20f2558733fbd218f4580fc7c3 (patch) | |
tree | ea4f80b43b08744d493bb86ab646444ec04ddc7f /misc/notify | |
download | inter-3b1fffade1473f20f2558733fbd218f4580fc7c3.tar.xz |
Initial public commitv1.0
Diffstat (limited to 'misc/notify')
-rwxr-xr-x | misc/notify | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/misc/notify b/misc/notify new file mode 100755 index 000000000..ab10e4e8e --- /dev/null +++ b/misc/notify @@ -0,0 +1,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 |