Why console prompt behaviour changed when added new color escape sequences to $PS1 in /etc/bashrc?

Solution Verified - Updated -

Issue

  • Changed the $PS1 parameter in /etc/bashrc as follows:
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\\033[1;33mUAT\\033[0m-[\u@\h \W]\\$ "
  • After making above changes the behaviour of console prompt got changed. When up key is pressed to view history, it prints random characters at the prompt.

  • For eg:
    Executed following commands:

   UAT-[root@localhost ~]# yum --nogpgcheck info /home/soft/oracle-validated-1.0.0-24.el5.x86_64.rpm 
and 
   UAT-[root@localhost ~]# ls

Then pressing up key prints weird characters as follows:

UAT-[root@localhost ~]# yum --nops -ef|more

Environment

  • Red Hat Enterprise Linux 5.8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In