Audio notification of success or failure after a command finishes. Useful for long-running commands.
ding rake db:migrateTo hear both sounds:
ding true
ding falseSounds: Obviously, you have to provide your own sound files. I got mine here.
| #!/bin/bash | |
| # Customize path by setting export DING_SOUND_DIR=/path/to/sounds in .bashrc | |
| : ${DING_SOUND_DIR:=$HOME/Dropbox/sounds} | |
| trap 'kill 0' INT TERM KILL | |
| success="$DING_SOUND_DIR/smw_coin.wav" | |
| failure="$DING_SOUND_DIR/smw_pipe.wav" | |
| player=$((which afplay &>/dev/null && echo afplay) || echo aplay) | |
| eval "$*" | |
| exit_code=$? | |
| case $exit_code in | |
| 0) | |
| sound="$success" | |
| ;; | |
| *) | |
| sound="$failure" | |
| ;; | |
| esac | |
| $player "$sound" & | |
| exit $exit_code |