How can I customize bash to add a system “bell” whenever a readline (prompt user for input) is requested?
Running (upgraded) bash 4.1.0 on Mac OS X 10.6 (Snow Leopard).
Add \[\a\]
to PS1
(normal prompt) and PS2
(continuing prompt), e.g.
PS1="\u@\h\[\a\] "
will make the normal prompt
username@hostname
including a bell.
\a
is the BELL
character, \[
and \]
tell the shell it's not printed (for width calculation).
Add the PS1=...
line to ~/.bash_profile
once you're happy with it.
This doesn't work for command-line based applications though. I don't think it's possible, since you can enter quite often input even while output is being printed; this accumulates. And a prompt just means nothing's currently writing to the terminal.
readline
input.
PS3
used for actual prompts in bash
scripts.