delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/24/15:08:12

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 24 Aug 2005 14:07:54 -0500 (CDT)
From: Suan Yong <suan AT cs DOT wisc DOT edu>
To: cygwin AT cygwin DOT com
Subject: readline clash with bash/PS1 escapes
Message-ID: <Pine.GSO.4.58.0508241353090.6757@alumni.cs.wisc.edu>
MIME-Version: 1.0

Hi,

After a recent cygwin update (including one just today), I'm seeing a bug
in the readline completion that I finally tracked down to the control
sequences in my PS1 for setting the title bar and coloring my prompt.  It
looks like the '\[' and '\]' delimeters are screwing it up.  Here are the
symptoms (~> is my prompt).

  ~>env | fgrep PS1
  PS1=\[\033]0;\W\007\]\[\033[32m\]\w>\[\033[0m\]

When I type: ls .<tab><tab>
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ls . .
----------^-----------------
Notice the extra " ." in the re-rendered line (^ indicates the prompt
position).  Something is clearly out of sync.
For example, if I then type: Control-U
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ls
----^-----------------------
where the prompt is overlapping the "ghost" letters "ls", which aren't
really in the buffer.  E.g., if I then type: p<enter>
I see:
----------------------------
  ~>ls .
  ./             .bash_history  .cvsrc         .ssh/          .vimrc
  ../            .bash_profile  .history       .vim/
  .Xdefaults     .bashrc        .inputrc       .viminfo
  ~>ps
  bash: p: command not found
  ~>
----^-----------------------
After some experimentation, I found that if I removed the '\[' and '\]'
delimiters from my PS1, the errant behavior goes away.  The
control sequences evidently still work, even though the man page for bash
suggests that they really should be enclosed within \[ \].

Suan

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019