bug-bash
[Top][All Lists]
Advanced

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

Re: Prompt messed up if PS1 contains ANSI escape sequences


From: Greg Wooledge
Subject: Re: Prompt messed up if PS1 contains ANSI escape sequences
Date: Thu, 7 Sep 2023 09:50:17 -0400

On Thu, Sep 07, 2023 at 03:46:23PM +0200, Gioele Barabucci wrote:
> On 07/09/23 15:00, alex xmb ratchev wrote:
> > u have to \[ esc-seq \]
> > eg inside \[ and \]
> > 
> > PS1=$'\u\[\e[1m\]\h\[\e[0m- '
> > 
> > should display hostname bold
> 
> Thanks for the suggestion, but adding \] does not really fix the problem, it
> just masks it in many cases (better than nothing).

The \[ \] wrappings are required.  They're not "masking" the problem.
Your prompt is literally set incorrectly without them.

>From the man page:

    PROMPTING
    [...]
              \[     begin  a sequence of non-printing characters, which could
                     be used to embed a terminal  control  sequence  into  the
                     prompt
              \]     end a sequence of non-printing characters

See also <https://mywiki.wooledge.org/BashFAQ/053> for more details.



reply via email to

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