Anomaly with bash PS1 definition

Posted by Michael Wiles on Ask Ubuntu See other posts from Ask Ubuntu or by Michael Wiles
Published on 2011-03-03T10:13:12Z Indexed on 2011/03/03 15:33 UTC
Read the original article Hit count: 351

Filed under:
|
|

My root and admin user both have the same .bashrc file.

The prompt section of the .bashrc is the following:

         if [ "$color_prompt" = yes ]; then
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
           else
                PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 
         fi 
         unset color_prompt force_color_prompt

         # If this is an xterm set the title to user@host:dir 
         case "$TERM" in xterm*|rxvt*)
                PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
                ;;
            *)
                ;; 
         esac

But the problem is that the admin user and root user have different prompts.

admin's prompt is:

admin@hostname:~$

and root's prompt is

root@hostname:/home#

So it seems root is using the "xterm" version and admin is not.

Why does the .bashrc file have this difference in prompts? How do I get the admin user to also use the xterm version?

How would I test that condition?

If I run echo $TERM while running as the admin user I get xterm so as far as I can tell, it should be using the xterm version for the admin user.

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about shell