[NBLUG/talk] Prompt configuration

Steve Zimmerman stevetux at sonic.net
Wed May 21 23:11:01 PDT 2003


On Monday 19 May 2003 04:10 pm, Steve Zimmerman
 wrote:
> Have you ever had this problem?
>
>   ]# cd
> ~]# pwd
> ~]# /root
>
>   ]$ cd
> ~]$ pwd
> ~]$ /home/steve

"Whoops!" says Steve Zimmerman.
Correction of errata:

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?
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/mailman/listinfo/talk



More information about the talk mailing list