[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Screen Corruption when browsing Command History with Custom Prompt
From: |
Ashley Wilson |
Subject: |
Re: Screen Corruption when browsing Command History with Custom Prompt |
Date: |
Wed, 10 Sep 2008 01:34:10 +1000 |
No, Wait! That's not the issue!! This works just fine:
PS1="\n\[\e[0;32m\]\u: \w\n# \[\e[m\]"
So, all I had to do was to add '\[' before and '\]' after the coloring
sequence to fix everything!
--
Regards,
Ashley.
On Wed, Sep 10, 2008 at 12:51 AM, Ashley Wilson <ashleyvjc@gmail.com> wrote:
> The escape sequence for adding colors are an exception - If you add
> backslashes to those brackets, it won't (and doesn't) work as
> expected.
>
> I tried what you said : Set
>
> PS1 = "\n\e\[0;31m\u: \w\n# \e\[m"
>
> The resulting prompt did, still, exhibit the corruption explained in
> my bug report, and the prompt appeared as follows:
>
> 0;31mroot: /home/ash
> #
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * * *
>
> It seems I shouldn't have used the \e character.. The default Ubuntu
> .bashrc has another way of doing it, which I tried to learn from. And
> it seems it works! Here is my working sequence (and no screen
> corruption!)
>
> PS1="\n\[\033[0;31m\]\u: \w\n# \[\033[00m\]"
>
> Note that not all square brackets are preceded with backslashes!
>
> Thanks for replying anyway. I was only trying to copy-paste from the
> web, but overlooked the example that was already in the default
> .bashrc !!
>
> Sorry for the trouble..
>
> --
> Regards,
> Ashley.
>
>
> On Tue, Sep 9, 2008 at 11:49 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>> Ashley Wilson wrote:
>>
>>> Repeat-By:
>>>
>>> Set a custom prompt using the PS1 variable as follows:
>>>
>>> PS1="\n\e[0;31m\u: \w\n# \e[m"
>>>
>>> Then, browse command history using up/down keys.
>>
>> As the documentation states, you need to bracket sequences of non-printing
>> characters in prompt strings with the \[ and \] escape sequences.
>>
>> Chet
>>
>>
>