help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] read -ep and ANSI colour sequences


From: Pierre Gaston
Subject: Re: [Help-bash] read -ep and ANSI colour sequences
Date: Wed, 20 Feb 2013 13:44:18 +0200

On Wed, Feb 20, 2013 at 1:39 PM, Chris Down <address@hidden> wrote:
> On 2013-02-20 13:33, Pierre Gaston wrote:
>> On Wed, Feb 20, 2013 at 1:30 PM, Chris Down <address@hidden> wrote:
>> > On 2013-02-20 06:18, Chris F.A. Johnson wrote:
>> >> read -ep $'\e[41;37;1m >> \e[0m '
>> >
>> > Whilst this is valid from bash2 onwards and should work fine, you should be
>> > aware that if you require POSIX compatibility down the line, this will 
>> > break.
>> >
>> > ( Yes, I am aware this is `help-bash', not `help-posix' ;-) )
>> >
>> > Chris
>> >
>> For some value of fine, afaik in both case readline will not wrap
>> correctly and I think there is no way to escape the terminal code like
>> in PS1
>
> \e[0m is the escape, unless you mean something else. It works for me:
>
>     $ read -ep $'\e[41;37;1m >> \e[0m ' ; echo "$REPLY"
>      >>  foo
>     foo
>
> Not sure what you mean about readline not wrapping correctly.
>
> Chris

I mean in PS1 you should surround the terminal codes with \[  \] so
that readline can calculate the length of the prompt correctly.

The problem appears when your answer reach the rightmost column of
your termina, it will wrap instead of going to the next line.
Try with and without colors in the prompt and type enough chars to
reach the end of the line and you will see.



reply via email to

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