ding: Audio Feedback for Exit Codes
Do you babysit long-running applications?
You could display a desktop notification, but it’s even nicer (and mouseless) to know how things went without looking.
My use case
I run mix test
in another tmux window; it’s “offscreen” for all intent and purposes.
I use entr to trigger mix test
: my tests will run when files change.
I want to know: did the tests pass?
Ding
That last one is more useful than it looks: if you already started something
and realize it’s going to take a while; type ding
and it will execute when
the first command finishes.
All together now:
Simple Enough
ding is a simple script:
- it runs your command
- grabs the exit code
- plays a sound for success (exit code == 0)
- plays a different sound for failure (exit code != 0)
Here’s the script as of the writing of this post:
Both afplay
and the .aiff
files assume a macOS environment.
But there’s so little logic here, it’s easy to adapt to your own needs.