Re: Add colors to the prompt for status indicators
- From
Kevin Ballard <kevin@sb.org>
- Date
- Nov 15, 2010, 22:52 UTC
- Message-ID
- <19363118-D147-4946-8973-B5DDA4B00985@sb.org>
- In-Reply-To
- <4CE04B82.1040804@pileofstuff.org>
On Nov 14, 2010, at 12:50 PM, Andrew Sayers wrote:
Show 6 quoted lines
> It's possible to work around this for a whole script:
>
> foo() {
> echo -e "\033[;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0m"
> }
> PS1='\[$(foo)'\]>'If $(foo) were to emit some actual printable characters, won't this make bash ignore them when calculating line lengths?
> As a fan of colourful prompts, I'd be very happy if you found a way > around this for parts of a script. But as a fan of fast prompts, I'd > prefer not to call __git_ps1 more than once :)
I don't think there is any way around this, besides patching bash to be intelligent and determine which PS1 characters are printable itself without relying on \[ and \].
-Kevin Ballard