[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xterm title bar change and prompt change



This may be hard to explain but I'll try.  I have this in my
/home/kent/.bashrc,

case $TERM in
     xterm*)
         PS1="\[\033]0;\u@\h: \w\007\]\w\$ "
         ;;
     *)
         PS1="\w\$ "
         ;;
esac


This displays user name or root@machine name:directory.
For example:
kent@xyf:/etc 
or
root@xyf:/etc

The prompt in my xterm in this example as a regular user would be,
/etc$

Ok, all that is fine till I su to root.  In order for any of this to
work I put the above script into my .bashrc while signed in as su root
and in the /root directory.  Then when I su to root I get the changes in
title bar BUT I don't get the prompt change.  My root prompt doesn't
change from "$" to "#" like I would like.  I have tried to change the
line  PS1="\w\$ " to export PS1="\w\$ " that did nothing.  

Ok to further complicate things if, as su root, I cd to the /root
directory the prompt looks like this, "~$" this confuses me sometimes
because I think I'm in /home/kent.  So to get around this in my .bashrc
in the /root directory (/root/.bashrc) I removed the title bar script
and just put this,
export PS1='$(pwd)\$ ' this works great because now when I cd to /root
the prompt shows /root#.  

As it stands the title bar displays what I want regardless if I'm a
regular user or root.  The way the prompt is displayed as a regular user
is fine but the root prompt lacks two things:
It does not change to "#" but remains "$".
Instead of displaying "/root#" while in the /root directory it displays 
"~$".

I looked at the Bash prompt howto and the script there doesn't work for
me.  I've tried various other scripts I have found on the net and this
is the only one I have found that even executes.  I've looked at man
bash and man xterm.  I'm using Slink and Bash version 2.3.10.
If anyone knows how I can fix this please let me know.
Thanks,
kent


Reply to: