Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question
up vote 4 down vote accepted

Add \[\a\] to PS1 (normal prompt) and PS2 (continuing prompt), e.g.

PS1="\u@\h\[\a\] "

will make the normal prompt


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.

share|improve this answer
Yeah, I don’t want a bell on my PS1 prompt. Basically, I’d like a bell if something is waiting for readline input. – Zearin Apr 30 '11 at 13:00
But close enough, I suppose. Maybe if I add this to one of the other PS# variables. I’ll have to check. (Anyway, thanks! ☺) – Zearin Sep 6 '11 at 12:41
@Zearin I also found out since, that there is PS3 used for actual prompts in bash scripts. – Daniel Beck Sep 6 '11 at 12:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.