[Top][All Lists]

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

Re: [Help-bash] color in bash read builtin prompt

From: Greg Wooledge
Subject: Re: [Help-bash] color in bash read builtin prompt
Date: Fri, 17 Oct 2014 08:45:12 -0400
User-agent: Mutt/

On Fri, Oct 17, 2014 at 08:37:30PM +0800, Clark Wang wrote:
> Try like this:
> read -p $'\033[1;31mRED:\033[0m ' var

While that "works" in the sense that it writes an escape sequence
to the terminal, bash has no clue how many printable characters are
in that prompt, and therefore has no clue where the cursor is.  So 
if you try to combine that with read's -e option, the wrapping will
break horribly.

As far as I know, there is NO fix for that.

You also hard-coded one particular terminal's escape sequence rather than
using tput to look it up using $TERM and the system's terminfo or termcap
databases.  Yes, I know that this one particular style of terminal has
"won" the terminal war, and now every newbie thinks that this is some
sort of universal code that works on any terminal, but it's not.

reply via email to

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