bug-bash
[Top][All Lists]
Advanced

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

Re: Buffer corruption when the terminal is resized.


From: Eduardo Bustamante
Subject: Re: Buffer corruption when the terminal is resized.
Date: Sat, 10 Jun 2017 11:58:03 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Sat, Jun 10, 2017 at 06:49:13PM +0200, Paul Peet wrote:
> declare -- PS1="\\[\\e]0;address@hidden:
> \\w\\a\\]\${debian_chroot:+(\$debian_chroot)}\\[\\033[01;address@hidden:\\[\\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;address@hidden:\w\a\$...'
        # ^      ^

instead.

-- 
Eduardo Bustamante
https://dualbus.me/



reply via email to

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