bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BUG: bash miscomputes size of prompt with ANSI escapes


From: Bernardo Innocenti
Subject: BUG: bash miscomputes size of prompt with ANSI escapes
Date: Tue, 29 May 2001 17:22:19 +0200

Hello,

I was trying to get a colorful prompt for my shell, and I've
tried this:

PS1='\033[31m\u\033[36m@\033[33m\h\033[36m:\033[32m\w \033[36m\$ \033[37m'

 I got the wanted result, but apparently bash (version 2.05.5) uses a
simple algorithm to compute the size of the prompt and so the cursor
wraps too early. It probably just counts the characters in the prompt.
I admit it's not possible to build a full parser for ANSI escapes inside
bash, but perhaps it's possible to get the cursor column back from the
terminal _after_ printing the prompt.

 I know using ANSI escapes in the prompt will make my shell incompatible
with any non-ANSI capable terminal. I would rather use an ncurses-aware
method, but I suppose there is no way to do it in PS1.

-- 
  // Bernardo Innocenti
\X/  http://www.codewiz.org/~bernie



reply via email to

[Prev in Thread] Current Thread [Next in Thread]