12

Is there a way to play OSX alert sounds from terminal? The alert sounds that are listed in System Preferences > Sound > Sound Effect Tab

19

If you have "audible bell" enabled in your Terminal Settings under Advanced, BEL control characters will sound the default alert sound.

To try this, issue the echo command followed by control+v control+g. If you type it right, it will look like this:

$ echo ^G

and when you press return, the alert will sound.

(control+v is a shell escape for the immediately-following control character.)

The afplay command can also be used to play a specific sound file:

$ afplay /System/Library/Sounds/Funk.aiff 
  • I use this for playing sounds in MAMP PRO: <? passthru('/usr/bin/afplay /System/Library/Sounds/Sosumi.aiff'); ?> – EDP Dec 17 '17 at 13:42
5

Another option, with less modifier keys, is to use the command tput bel.

  • I liked this answer because I disabled the "audible bell" in my terminal settings, but tput bel calls the "visual bell" so I still get the alert that I want without the noisy one – Purefan Jan 26 '16 at 9:22
4

I like zigg's solution. In order to keep it short I did this:

In /Users/{username}/.bash_profile add a line

alias taskready='afplay /System/Library/Sounds/Hero.aiff'

Quit the terminal and open the terminal. Now you can use the shorthand command taskready.

You can choose from:

Basso.aiff  Frog.aiff   Hero.aiff   Pop.aiff    Submarine.aiff
Blow.aiff   Funk.aiff   Morse.aiff  Purr.aiff   Tink.aiff
Bottle.aiff Glass.aiff  Ping.aiff   Sosumi.aiff
  • 2
    done is used in bash to close for/while loops, maybe a different name might be better – nohillside Aug 29 '19 at 7:24
  • @nohillside it luckily didn't cause any problems so far... thanks! Do you have a short keyword suggestion? – Matt Aug 30 '19 at 16:35
  • 1
    See man bash for all keywords to avoid :-) – nohillside Aug 30 '19 at 16:49
2

Another way to beep is echo -e '\a'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .