The Computer Oracle

Play sound on mac terminal

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Ancient Construction

--

Chapters
00:00 Question
00:25 Accepted answer (Score 182)
00:54 Answer 2 (Score 22)
01:07 Answer 3 (Score 6)
01:30 Answer 4 (Score 5)
01:49 Thank you

--

Full question
https://superuser.com/questions/598783/p...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #terminal #alert

#avk47



ACCEPTED ANSWER

Score 194


printf \\a and osascript -e beep play the default alert sound, but they are silent if the alert volume is set to zero. printf \\a is also silent if an audible bell is disabled.

You could also use afplay or say:

afplay /System/Library/Sounds/Funk.aiff
say done

There are more sound effect files in /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/.




ANSWER 2

Score 26


The simplest way is the use a bell echo -e "\a"




ANSWER 3

Score 7


tput bel works in most shells.

From this answer on a related Stack Overflow question:




ANSWER 4

Score 6


Another way is to echo ^G. But you don't literally type the ^G. Instead, type ctrl+v, ctrl+g, which will appear as echo ^G.