Linux – How to ring the audio bell within a bash script running under gnu screen

bashgnu-screenkonsolelinuxterminal

In a konsole terminal window outside of screen running a bash shell with TERM set to konsole-256color if I type:

echo -n $'\a' or
echo -n $'\eg' or
./ringbell where contents of ./ringbell is

#!/bin/bash
echo -n $'\eg';echo -n $'\a'

They all result in the configured audio bell going off. If I enter a screen session (my .screenrc also sets term to konsole-256color) only the second of the above 3 commands (echo -n $'\eg') result in the audio bell being heard. Do I have to modify the script or is this an issue with screen?

The ubuntu version of screen package I have is 4.1.0~20120320gitdb59704-9.

Best Answer

From memory, Ctrl-G is the bell character, so I think that's why the second one worked. But screen can be picky over what characters it accepts as it takes Ctrl-A as the command code.

Try this

#!/bin/sh
# Ring the terminal bell
# echo "\a" # does not work in some shells
tput bel

I found this on rosettacode, hopefully it will give you some options

Related Question