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

I am running Red Hat 5 32-bit (2.6.18-194.26.1.el5).

The issue is that when I recall any previous command in bash's history, the first character in the command is displayed immediately after the shell prompt, without any intervening space, likeso:

\[me@mymachine tmp]$man mysql

If I enter a Ctrl-C, and retype the command, it looks likeso:

\[me@mymachine tmp]$ man mysql

This makes recalling a command and editing it before re-entering a real pain. Basically, if I try to edit a recalled command, my changes occur one character position to the left (I believe) of what I see on the screen. It's a bit tedious to describe, and appears to only happen with commands with a large number of arguments.

UPDATE: The contents of /etc/sysconfig/bash-prompt-screen,

1 #!/bin/bash
2 echo -n $'\033'"_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"$'\033\\\\'

and the contents of /etc/bashrc,

 24   screen)
 25     if [ -e /etc/sysconfig/bash-prompt-screen ]; then
 26       PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
 27     else
 28     PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
 29     fi
 30     ;;

I've disable bash-prompt-screen by renaming it--this fixed it. It's entirely possible that there is a fix to the bash-prompt-screen prompt line in the latest version of screen for RHEL 5. The error is seen under Screen version 4.00.03 (FAU) 23-Oct-06. (I noticed an update in the queue, which is installing as I write this.)

share|improve this question
up vote 1 down vote accepted

Your prompt has an error in its definition. It should be of the form:


For example:

PS1='\[\033[1;36m\]\u\[\033[0m\]@\[\033[1;34m\]\h\[\033[0m\]\$ '

which would show as a cyan username and a blue hostname.

Somehow, you're getting a literal \[ in the output. Check your literal and escaped brackets to make sure they're correct.

share|improve this answer
@vergueishon: My guess is that there's two too many backslashes at the end of the line in that file. – Dennis Williamson Feb 4 '11 at 20:14

has an extra '\'

This means we need to shorten it to the following to make the extra '\' go away!

echo -n $'\033'"_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"$'\033\\'

Note: good news! This is only a screen setting.

share|improve this answer

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.