On Mon, Mar 21, 2022 at 05:00:29PM +0800, Michaelll Lee wrote:
> By the way,  apparently the content about "non-printing characters" in that
> man page has not been modified across the several versions of Bash, for
> example in my machine, "3.2.57(1)-release" and "5.1.0(1)-release" share
> nearly the same document for section "PROMPTING", and both of them have not
> mentioned about the necessity to wrap around the non-printing characters
> with "\[...\]".

It's in the list of backslash-escaped special characters:

       abled.   Bash allows these prompt strings to be customized by inserting
       a number of backslash-escaped special characters that  are  decoded  as
       follows:
              \a     an ASCII bell character (07)
              \d     the  date  in "Weekday Month Date" format (e.g., "Tue May
                     26")
       [...]
              \\     a backslash
              \[     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

Remember also that the manual (either the texinfo version or the man page)
is written as a reference, not a tutorial.  All of the information that
you need is in there, but it's not necessarily laid out in the way that's
best for learning it from a newcomer's point of view.

Reply via email to