1
1
mirror of https://github.com/rsms/inter.git synced 2024-11-23 20:55:33 +03:00
inter/misc/notify

42 lines
1007 B
Plaintext
Raw Normal View History

2017-08-22 10:05:20 +03:00
#!/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