[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Buffer corruption when the terminal is resized.
From: |
Paul Peet |
Subject: |
Re: Buffer corruption when the terminal is resized. |
Date: |
Sat, 10 Jun 2017 19:21:36 +0200 |
If I understand this correctly this prompt (see below) shouldn't
contain any invisible sequence, therefore it doesn't require the
wrapping with \[ and \].
PS1="\u@\h\$"
So bash should be able to correctly calculate the prompt size and
such, but by resizing the window it still results in a corrupted
buffer.
I've uploaded another gif which shows this:
https://media.giphy.com/media/xUA7biW8UtwYIU6ggg/giphy.gif
On Sat, Jun 10, 2017 at 6:58 PM, Eduardo Bustamante <dualbus@gmail.com> wrote:
> On Sat, Jun 10, 2017 at 06:49:13PM +0200, Paul Peet wrote:
>> declare -- PS1="\\[\\e]0;\\u@\\h:
>> \\w\\a\\]\${debian_chroot:+(\$debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\\$
>> "
> [...]
>> > Bash relies on \[ and \] to determine how much space is occupied by the
>> > prompt when it is to be redrawn, so in this case it thinks the prompt is 2
>> > columns wider than it actually is.
>
> George already said it. There are two types of characters inside the
> prompt string, visible and invisible. Color sequences are of the
> invisible kind (these have an effect on the terminal, but do not occupy
> any space on the line). You must wrap invisible character sequences with
> \[ and \], otherwise Readline's calculation to figure out the physical
> lenght of your prompt string will be off, and will cause the effect that
> you're experiencing.
>
> Try with:
>
> # vvvvv- this is an invisible sequence.
> PS1='\[\e]0;\]\u@\h:\w\a\$...'
> # ^ ^
>
> instead.
>
> --
> Eduardo Bustamante
> https://dualbus.me/
- Buffer corruption when the terminal is resized., Paul Peet, 2017/06/10
- Re: Buffer corruption when the terminal is resized., Eduardo Bustamante, 2017/06/10
- Re: Buffer corruption when the terminal is resized., George, 2017/06/10
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/10
- Re: Buffer corruption when the terminal is resized., Eduardo Bustamante, 2017/06/10
- Re: Buffer corruption when the terminal is resized.,
Paul Peet <=
- Re: Buffer corruption when the terminal is resized., Eduardo Bustamante, 2017/06/10
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/10
- Re: Buffer corruption when the terminal is resized., Eduardo Bustamante, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Chet Ramey, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Chet Ramey, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Chet Ramey, 2017/06/12
- Re: Buffer corruption when the terminal is resized., Paul Peet, 2017/06/12