Is there a way to play OSX alert sounds from terminal? The alert sounds that are listed in System Preferences > Sound > Sound Effect Tab
5 Answers
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'); ?>– EDPDec 17, 2017 at 13:42
Another option, with less modifier keys, is to use the command tput bel
.
-
2I 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– PurefanJan 26, 2016 at 9:22 -
Today, the accepted answer (
echo
ctrl+v ctrl+g) also shows the visible bell when my Mac is muted. Glad they fixed this since 2016– Ky -Jul 8, 2020 at 15:15
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, 2019 at 7:24 -
@nohillside it luckily didn't cause any problems so far... thanks! Do you have a short keyword suggestion?– MattAug 30, 2019 at 16:35
-
1