[Nottingham] Re: bash prompt

James Gibbon james.gibbon at virgin.net
Thu Jun 10 15:28:53 BST 2004


On Thu, 10 Jun 2004 14:19:03 +0100 (BST)
Martin Garton <martin at wrasse.demon.co.uk> wrote:

> 
> Following on from Martin's excellent bash talk, here is the prompt I 
> mentioned to one or two people that makes use of a couple of the things we 
> discussed at the talk.
> 
> export PS1="$PS1 \`if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi\`"
> 
> For those who I didn't mention it to, it should be easy to work out what 
> it does, and even easier to try it.

Nice idea!  But you shouldn't have to escape the colons.

This worked for me - backticks are deprecated, and you save another character! ;)

export PS1="$PS1 \$([ \$? = 0 ] && echo :\) || echo :\()"

.. the truly retentive might prefer

export PS1="$PS1 \$([[ \$? = 0 ]] && echo :\) || echo :\()"

.. which uses an internal test.



james



More information about the Nottingham mailing list