Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we play sound alarm after command is done on Mac terminal?

When we run a command that takes a while such as source compile or brew upgrade, we usually do other things such as web searching rather than watching the command running the whole time.

Is there any possible way that I can get notified once the command is done?

brew upgrade | afplay /System/Library/Sounds/Submarine.aiff -v 10

I tried with afplay on Mac as above but the problem is a) stdout is not shown due to the pipe, b) it plays the sound right after the command starts to run rather than waiting until "brew upgrade" is finished.

Any suggestions please?

like image 308
ronnefeldt Avatar asked Nov 09 '13 12:11

ronnefeldt


People also ask

How do I play sound on my Mac?

Unplug any headphones or external speakers. On your Mac, choose Apple menu > System Preferences, click Sound , then click Output. Make sure “Internal Speakers” is selected, the “Output volume” slider is not all the way to the left, and the Mute checkbox is not selected.

What does caffeinate do in Mac terminal?

The Terminal command caffeinate works on every Mac, is instant, and is easy to stop. And you don't even have to remember how to spell the word: just type "caf" and hit tab . The Mac will complete the word for you. It's effective, and it makes you look way cooler than you are.

How do I turn off sound in Terminal Mac?

On the menu go to Terminal > Window Settings. In the Terminal Inspector window click on the drop-down list and select Emulation. Un-check the "Audible Bell" option. (You can also set "visible bell" which will cause your terminal to flash instead of beep)


1 Answers

brew upgrade && say brew upgrade done

leverage the say command and get a custom voice notification

general example:

YOUR_COMMAND && say YOUR_COMMAND done

like image 182
Giorgio Avatar answered Nov 06 '22 13:11

Giorgio