I present in this answer two things:
- The option of using
afplay
, which plays sound files, for notification.
- my tools for reporting exit status along with the notification.
I have this script, ~/bin/donebeep
:
#!/bin/bash
if [ "$@" = 0 ]; then
afplay -v 2 /System/Library/Sounds/Blow.aiff &
else
afplay -v 2 /System/Library/Sounds/Sosumi.aiff &
fi
This plays a different sound depending on whether the argument is 0. Then I have an alias:
alias donebeep='(savestatus=$?; ~/bin/donebeep $savestatus "$@"; exit $savestatus)'
(That they have the same name is irrelevant and probably a bad idea.)
To use it in your example, svn update . && ant clean build start; donebeep
. Note that I am using ;
rather than &&
, so that it can notify me on failure as well as success.
Before I learned about afplay
, I used say
to speak messages instead. The role of donebeep
was played by this script:
#!/bin/bash
say -v Bruce "Done $(basename "$(pwd)"), $@." &
This script speaks the exit code directly instead of having two different messages. It also mentions the name of the current directory (to help clarify which task is done), and can be given additional text to say by passing parameters to the alias (that's why the alias has "$@"
in it). Note the trailing &
so that you do not need to wait for the speech to finish before getting a prompt.
The man page for afplay
is incomplete; afplay -h
lists all options:
Usage:
afplay [option...] audio_file
Options: (may appear before or after arguments)
{-v | --volume} VOLUME
set the volume for playback of the file
{-h | --help}
print help
{ --leaks}
run leaks analysis {-t | --time} TIME
play for TIME seconds
{-r | --rate} RATE
play at playback rate
{-q | --rQuality} QUALITY
set the quality used for rate-scaled playback (default is 0 - low quality, 1 - high quality)
{-d | --debug}
debug print output