Skip to content

Instantly share code, notes, and snippets.

@divad12
Created December 6, 2013 03:13
Show Gist options
  • Save divad12/7817989 to your computer and use it in GitHub Desktop.
Save divad12/7817989 to your computer and use it in GitHub Desktop.
Announces and displays exit code of last run command. Try `sleep 5; notify`
# Announces and displays exit code of last run command.
# eg. `sleep 5; notify`
function notify {
status=$?
if [ $status -eq 0 ]; then
echo -e "\033[1;32m[ DONE ]\033[0m"
( say -v Cellos `printf "%0.s done" {1..26}` & )
elif [ $status -ne 130 ]; then # Ignore exit with Ctrl-C
echo -e "\033[1;31m[ ERROR $status ]\033[0m"
( say "Oh noes, exit code $status" & )
fi
return $status
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment