Set up sound notification when bash command is done
Aug 13, 2024/
#bash
/-1 minWhen 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.
1npm install && say "npm install done"
If you want to add a tiny sound before the voice, you can use the
afplay
command.
1npm install && afplay /System/Library/Sounds/Funk.aiff && say "npm install done"
You can convert this script into an alias.
1notify() {
2 local message=$1
3 shift
4 local command="$@"
5 eval "$command" && afplay /System/Library/Sounds/Funk.aiff && say "$message"
6}
You can now use it below:
1notify "npm install done" "npm install"
Notes
- You can list voices using the
command. For example, I can usesay -v \?
voice for texts in Turkish.Yelda
1say -v Yelda "Selamlar"