Date: Wed, 25 Apr 2018 21:05:26 -0400 From: "Garance A Drosehn" <drosih@rpi.edu> To: tech-lists@zyxst.net Cc: freebsd-questions@freebsd.org Subject: Re: bash history buffer output mangled after repeated up-arrow Message-ID: <E20E5533-207C-4C2A-8C06-A76CB6248192@rpi.edu> In-Reply-To: <20180425142605.GA39933@desktop.local> References: <20180425142605.GA39933@desktop.local>
next in thread | previous in thread | raw e-mail | index | archive | help
On 25 Apr 2018, at 10:26, tech-lists@zyxst.net wrote: > hi, > > I've noticed now, for a while (like maybe over a year) that if you're in > bash shell, hitting up-arrow (which usually loads history -1) multiple > times will result in part of history becoming the prompt. When I've seen this, it has been because: 1) bash thought the width of the current window had a different number of columns than it actually has. or 2) the variable $PS1 is set to some custom value, and that value includes some characters use up either more or less than one column-width. In my case, case #2 happens when I'm playing games to set specific colors in my prompt. So, for instance, my PS1 includes the string '\e[1;34;47m' which sets the color of both the background and the text. However, all those characters will use up zero columns when displayed. Bash needs to know that all those characters use up zero columns, so those characters need to be surrounded by '\[' and '\]'. Thus the string really needs to be: '\[\e[1;34;47m\]' I think there are some other 'tty' settings which can also cause the behavior that you're seeing, but I don't remember which ones. -- Garance Alistair Drosehn = drosih@rpi.edu Senior Systems Programmer or gad@FreeBSD.org Rensselaer Polytechnic Institute; Troy, NY; USA
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E20E5533-207C-4C2A-8C06-A76CB6248192>