Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I am trying to set my bash prompt to display the time and current directory in bold:

export PS1="\[\e[1m\][\A] \w \$ \[\e[0m\]"

This does apparently work, but when I use the command history (ctrl-r), after finding the command I was searching for and pressing enter, this line is not displayed correctly. Here is an example:

[21:58] ~/Wyona/svn-repos/zwischengas $ 
(reverse-i-search)`ta': tail -F logs/log4j-cnode1.log

becomes, after pressing enter:

[21:58] ~/Wyona/svn-repos/zwischengas $  -F logs/log4j-cnode1.log

Of course, this is not "really" a problem, since the command does work correctly, but it is still annoying. Does anybody know why this happens? And, more importantly, how to prevent/fix it?

share|improve this question

migrated from May 23 '10 at 22:42

This question came from our site for professional and enthusiast programmers.

The \\[ and \\] are supposed to take care of what you're describing and you have a very straightforward prompt. What version of Bash (echo $BASH_VERSION)? – Dennis Williamson May 23 '10 at 21:44
Your PS1 works fine for me without the side effects you describe. What version of OS X are you using? I'm on 10.6.3 using the bash distributed with OS X (version string: GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)) – Doug Harris May 24 '10 at 14:58
I have this problem also. I can reproduce the problem above on Snow Leopard. /bin/bash is GNU bash, version 3.2.48(1)-release – Stefan Lasiewski Dec 21 '11 at 20:48

I can reproduce this with the system bash on 10.5.0 through 10.6.4, and this appears to be a bug in bash 3.x.


Install a new, more up to date bash (4.x) (my preferred path is Homebrew, found on github), and it should be fixed (it is for me).

share|improve this answer

I was seeing this, too, and fixed it by jumping into Preferences > Settings > [whichever one is your default] > Advanced and setting "Declare Terminal As" to "xterm-256color", then restarting Terminal.

share|improve this answer

You must log in to answer this question.