[Nottingham] bash prompt

Martin martin at ml1.co.uk
Thu Jun 10 15:56:09 BST 2004


Martin wrote:
> Martin Garton wrote:
[...]
>>
>> export PS1="$PS1 \`if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi\`"
>>
[...]

A small tweak (hack into your Mandrake /etc/bashrc):

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W :\`if [ \$? = 0 ]; then 
echo \); else echo \(; fi\`]\\$ "

(All on one line!)

Or (inspired by J.G.):

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W :\$([ \$? = 0 ] && echo \) 
|| echo \()]\\$ "

(All on one line!)


If non-Mandrake or using your ~/.bashrc, you'll likely need to drop the 
"[ ... ] &&" test.


Have fun,
Martin

(;-))

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list