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'); ?>– EDPCommented Dec 17, 2017 at 13:42
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 ♦Commented Aug 29, 2019 at 7:24 -
@nohillside it luckily didn't cause any problems so far... thanks! Do you have a short keyword suggestion?– MattCommented Aug 30, 2019 at 16:35
-
1
-
A slight variation: add a
&
after the command, so that it gets executed in the background, instead of holding up the shell—even if the sound itself is short, the sound file may actually last for multiple seconds.– CykeleroCommented Aug 29 at 19:19
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– PurefanCommented Jan 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 -Commented Jul 8, 2020 at 15:15
Not exactly what OP wants but may still prove useful to people.
say beep
or something even more specific:
say "task has finished"