Bash: Setting Prompt

albi albi at scii.nl
Wed May 18 03:37:38 PDT 2005


On Wed, 18 May 2005 06:26:53 -0400 (Eastern Standard Time)
Gerard Seibert <gerard-seibert at rcn.com> wrote:

> PS1="\u@\h \w "
> case 'id -u' in
>  	0) PS1="${PS1}# ";;
>  	*) PS1="${PS1}$ ";;
> esac
--- cut ---
> It is suppose to set the prompt to display the 'user at host' and the working 
> directory with a '#' for root and '$' for user. Everything works except 
> for the '#' and '$' symbols. The '$' symbol is always displayed.

this is what i use :

case $UID in
                0) PS1="\[\033[1;31m\][ \u@\h:\w] #\[\033[0m\] ";;
                *) PS1="\[\033[2;36m\][ \u@\h:\w] $\[\033[0m\] ";;
        esac

you could use this and remove the colours if you like



More information about the freebsd-questions mailing list