From owner-freebsd-questions@freebsd.org Thu Apr 26 01:10:42 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 272D8FB4B57 for ; Thu, 26 Apr 2018 01:10:42 +0000 (UTC) (envelope-from drosih@rpi.edu) Received: from smtp9.server.rpi.edu (gateway.canit.rpi.edu [128.113.2.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "canit.localdomain", Issuer "canit.localdomain" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E2817AC86 for ; Thu, 26 Apr 2018 01:10:40 +0000 (UTC) (envelope-from drosih@rpi.edu) Received: from smtp-auth1.server.rpi.edu (smtp-auth1.server.rpi.edu [128.113.2.231]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id w3Q15QFw020747 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Apr 2018 21:05:27 -0400 Received: from smtp-auth1.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth1.server.rpi.edu (Postfix) with ESMTP id AD95558019; Wed, 25 Apr 2018 21:05:26 -0400 (EDT) Received: from [172.16.67.1] (gilead-qc124.netel.rpi.edu [128.113.124.17]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: drosih) by smtp-auth1.server.rpi.edu (Postfix) with ESMTPSA id 982C558002; Wed, 25 Apr 2018 21:05:26 -0400 (EDT) From: "Garance A Drosehn" To: tech-lists@zyxst.net Cc: freebsd-questions@freebsd.org Subject: Re: bash history buffer output mangled after repeated up-arrow Date: Wed, 25 Apr 2018 21:05:26 -0400 X-Mailer: MailMate (1.11.1r5471) Message-ID: In-Reply-To: <20180425142605.GA39933@desktop.local> References: <20180425142605.GA39933@desktop.local> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing, @@RPTN) X-Spam-Score: 0.00 () [Hold at 10.10] X-CanIt-Incident-Id: 02VCN5qka X-CanIt-Geo: ip=128.113.124.17; country=US; region=New York; city=Troy; latitude=42.7495; longitude=-73.5951; http://maps.google.com/maps?q=42.7495,-73.5951&z=6 X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.229 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2018 01:10:42 -0000 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