4

I have a weird issue where my Bash prompt often completely disappears on a backspace. Doesn't make any sense to me, but it happens often:

enter image description here enter image description here

I can't really think of why this is happening. Am I overlooking some configuration file or something?

Here's my PS1 prompt:

PS1='\[\e]2;\u@\h\a\u@\h \W \$ '
  • 2
    It would help if you posted your $PS1. Otherwise my blind guess is you may not have it wrapped in \[ \]. – jw013 Oct 6 '11 at 21:17
  • Posted: PS1='\[\e]2;\u@\h\a\u@\h \w \$ ' – Naftuli Kay Oct 6 '11 at 23:04
  • I can reproduce the problem with that PS1. Type a few characters, backspace over them and whoosh, there it goes. – Paul Tomblin Oct 7 '11 at 0:20
  • What does that PS1 accomplish that PS1='\u@\h \W \$' doesn't? – Paul Tomblin Oct 7 '11 at 0:22
  • Writing username@host into the actual shell title. – Naftuli Kay Oct 7 '11 at 0:33
9

As I suspected in my comment, you are missing a \] in your PS1. Try this one:

PS1='\[\e]2;\u@\h\a\]\u@\h \W \$ '

For comparison, the original is

PS1='\[\e]2;\u@\h\a\u@\h \W \$ '
#                  ^ missing \]
0

Check if something running is blanking your PS1 env variable.
As an example on another machine not affected by that problem if you run

PS1=""

in a bash shell you will get the same output of your screen-shots.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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