Last active
August 7, 2025 20:24
-
-
Save jonpryor/63871805c0e957e747ac2f992644e589 to your computer and use it in GitHub Desktop.
macOS script which executes the command line, and when the command finishes posts a macOS notification that the command has finished, it's time(1) info, and the exit code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
TIMEFILE=`mktemp -t exec-notify` || exit 1 | |
EXIT_CODE=0 | |
/usr/bin/time -o "${TIMEFILE}" "$@" || EXIT_CODE=$? | |
cat "${TIMEFILE}" | |
echo exit=$EXIT_CODE | |
MESSAGE="exec “$1 …”\ntime: `cat ${TIMEFILE}`\nexited: $EXIT_CODE" | |
rm "${TIMEFILE}" | |
osascript -e "display notification \"$MESSAGE\" with title \"Terminal.app\"" | |
exit $EXIT_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: