[NBLUG/talk] Prompt configuration
Steve Zimmerman
stevetux at sonic.net
Mon May 19 16:09:00 PDT 2003
Have you ever had this problem?
]# cd
~]# pwd
~]# /root
]$ cd
~]$ pwd
~]$ /home/steve
The prompt uses the tilde to represent the /root directory when I'm
superuser; the prompt uses the tilde to represent /home/steve when I'm
regular user. This annoyed me until I found a fix, which is as follows
(in Red Hat 7.2).
The default prompt configuration is in /etc/bashrc. I commented out
the following line:
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
I replaced it with:
ROOT_UID=0
[ "$PS1" = "\\s-\\v\\\$ " ] && if [ "$UID" -eq "$ROOT_UID" ]
then
PS1="[\u at h \$(pwd)]\\$ "
else
PS1="[\u@\h \W]\\$ "
fi
Now my prompt says /root when I'm in that directory as superuser,
and my prompt says ~ when I'm in /home/steve.
Success--she is sweet, non?
More information about the talk
mailing list