Playing alert sounds from terminal

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


Solution 1:

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 

Solution 2:

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

Solution 3:

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

Solution 4:

Not exactly what OP wants but may still prove useful to people.

say beep