July 22, 2024 /
1 min /
#bash
#terminal
#productivity
Setup sound notification when bash command is done
When I run a command that takes a long time, I realize too late that it’s completed while I’m doing other things. That’s why I created an audible notify system using the script below.
npm install && say "npm install done"
If you want to add a tiny sound before the voice, you can use the afplay
command.
npm install && afplay /System/Library/Sounds/Funk.aiff && say "npm install done"
You can convert this script into an alias.
notify() { local message=$1 shift local command="$@" eval "$command" && afplay /System/Library/Sounds/Funk.aiff && say "$message"}
You can now use it below:
notify "npm install done" "npm install"
Notes
- You can list voices using the
say -v \?
command. For example, I can useYelda
voice for texts in Turkish.Terminal window say -v Yelda "Selamlar"