7

How can I generate audio bell in xterm type terminal?

Pablo
  • 28,133
  • 34
  • 125
  • 215

3 Answers3

16

Simple, print the bell character. In Python:

print('\a')

From bash shell:

echo $'\a'

Note that on some terminals, the bell can be disabled. In others, the bell can be replaced with a visual bell in the shape of a flashing screen background.

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
3
print("\a") # Python 3

or

print "\a"  # Python 2

See the docs.

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
2

For a simple beep, print "\a".

The Control Codes are listed on this page, these are all the characters that should make a terminal perform an action.

Serdalis
  • 10,296
  • 2
  • 38
  • 58