Sound effects for commands completing in inactive tabs/windows I think my life would be that much better if a subtle sound effect was played when a task completed in a terminal window/tab that's not the current one. It'd be even better if an exit code 0 sounded different to any other exit code.

Is there any way to make this happen?

(I often start little scripts in a window, like uploading a file to a server, then switch to another tab to do something on the server. It'd be great to hear when the file has arrived.)
It's certainly achievable if you're using scripts, I often use

tput bel


at the point where work is complete. This will not only beep the terminal but put a badge on the dock icon as well.

In terms of handling exit codes then you can string a couple together for a different sound:

if command_or_exit_status
then
# exit OK
        tput bel
else
# not ok
        tput bel; tput bel;
fi