Skip to content

Instantly share code, notes, and snippets.

@stevenhao
Created October 26, 2016 17:45
Show Gist options
  • Save stevenhao/c2ad80f1e19323279793814c70f80e52 to your computer and use it in GitHub Desktop.
Save stevenhao/c2ad80f1e19323279793814c70f80e52 to your computer and use it in GitHub Desktop.
#!/bin/bash
CMD_STR=""
for I in $@; do
CMD_STR="$CMD_STR $I"
done
TMP_FILE=/tmp/note-$$
touch $TMP_FILE || echo "meed write permissions to $TMP_FILE"
$@ 2> >(tee $TMP_FILE >&2)
EXIT_STATUS=${PIPESTATUS[0]} # exit status
ICON1=/Users/stevenhao/Dropbox/note-green.png
ICON2=/Users/stevenhao/Dropbox/note-red.png
if [ $EXIT_STATUS = 0 ]; then
head -n1 $TMP_FILE | terminal-notifier -contentImage $ICON1 -title 'Success' -subtitle "$CMD_STR"
else
head -n1 $TMP_FILE | terminal-notifier -contentImage $ICON2 -title 'Error' -subtitle "$CMD_STR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment