The Computer Oracle

Play sound on mac terminal

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay

--

Chapters
00:00 Play Sound On Mac Terminal
00:17 Accepted Answer Score 194
00:43 Answer 2 Score 26
00:52 Answer 3 Score 9
01:09 Answer 4 Score 7
01:26 Answer 5 Score 6
01:38 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.