Exporting $PS1.

David Jensen djensen at inebraska.com
Sat Mar 17 19:32:48 PDT 2007

Ag. Hatzimanikas wrote:
> would rather see a different color prompt for the root (red) and for 
> user (green maybe) - for obvious reasons. 
> if [[ ${EUID} == 0 ]] ; then
> 	PS1='\e[0;31m\u@\h:\e[0;39m\w\$ '
> 	else
> 	PS1='\e[0;32m\u@\h:\e[0;39m\w\$ '
> fi
hmmm, those confuse my cursor, especially in history.  Up-arrow is 
really a crap shoot.

I use this, cobbled up from an old, (really old) Gentoo I believe.

PS1='\[\e[1;32m\]\u [ \[\e[00m\]\w \[\e[1;32m\]]\$ \[\e[00m\]'

I don't know why the escaped bracing helps. 
Also the'\e[00m' restores default rather than the \e[0;39m you have used.
'1;' I use for bright colors.

David Jensen

More information about the blfs-dev mailing list