[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trouble with PS1 special characters between \[ and \]
From: |
Clark J. Wang |
Subject: |
Re: Trouble with PS1 special characters between \[ and \] |
Date: |
Sun, 31 Oct 2010 21:24:24 +0800 |
2010/10/31 Lluís Batlle i Rossell <viriketo@gmail.com>
> Hello,
>
> I don't think this problem is related to any recent bash version only. I've
> seen
> this since years I think.
>
> Nevertheless I'm using GNU bash, version 4.0.17(1)-release
> (x86_64-unknown-linux-gnu) now.
>
> My PS1 uses the "Change window title" sequence, to set the xterm window
> title to
> something close to the prompt text. Hence my PS1 is:
>
> PS1='\[\033]2;\h:\u:\w\007\]\n\[\033[1;31m\][\u@\h:\w]\$\[\033[0m\] '
>
> The ESC ] 2;.....BEL command, which has \h, \u and \w sequences in the
> middle,
> has problems on the length of the printable part of the prompt, as those
> usual
> when typing terminal control sequences without \[ \]. With the difference
> that I
> typed all the \[ \].
>
> May bash be having trouble, if it finds any of its own special backslash
> characters (\h, \u, \w) in the middle of a non-printable sequence marked
> with \[
> and \] ?
>
My understanding is that chars enclosed between \[ and \] are considered by
Bash to be of zero-length.
>
> Regards,
> Lluís.
>
>