extra-prompt.sh

David Jensen djensen at inebraska.com
Sun Jul 29 07:54:56 PDT 2007


taipan67 wrote:
>>>> if [[ ${EUID} == 0 ]] ; then
>>>> 	PS1='\[\e[1;31m\]\u [ \[\e[00m\]\w \[\e[1;31m\]]\$ \[\e[00m\]'
>>>>         else
>>>> 	PS1='\[\e[1;32m\]\u [ \[\e[00m\]\w \[\e[1;32m\]]\$ \[\e[00m\]'
>>>> fi
>>>>       
>>>>         
>> This is too cryptic.  Use:
>>
>> NORMAL="\[\033[0;39m\]"
>> RED="\[\033[1;31m\]"
>> GREEN="\[\033[1;32m\]"
>>     
I don't see \033 as preferable to \e, otherwise it looks OK.
Perhaps the bold/bright, '1' could be dropped, most others likely don't 
use a white on black xterm as I do.

thus:
    NORMAL="\[\e[0m\]"
    RED="\[\e[31m\]"
    GREEN="\[\e[32m\]"

Maybe single quotes, though there is nothing, as is, that bash will mangle.

Does anyone know why the escaped bracketing is required, it is.
It seems "\e[1;31m" should work but the cursor position and scrolling 
get fouled.

>> if [[ ${EUID} == 0 ]] ; then
>>   PS1="$RED\u [ $NORMAL\w$RED ]\$ $NORMAL"
>> else
>>   PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
>> fi
>>
>>   -- Bruce
>>   
>>     
> <snip> They also define 'normal' as "\[\033[00m\]" (not sure of 
> the difference).
>
>   
This seems incorrect to me, 00m is default mode, not a color.  It does 
however, set the default color and attribute.  Either '\e[00m' or 
'\e[0;39m'  seem correct.

Reviewing this thread 
http://linuxfromscratch.org/pipermail/blfs-dev/2007-March/016818.html
it seems PS1 should not be exported, no decision was reached

---
David Jensen




More information about the blfs-dev mailing list