delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/03/02/13:17:42

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-Id: <5.0.2.1.2.20010302100538.02e24688@ks.teknowledge.com>
X-Sender: rschulz AT ks DOT teknowledge DOT com
X-Mailer: QUALCOMM Windows Eudora Version 5.0.2
Date: Fri, 02 Mar 2001 10:12:34 -0800
To: "David A. Cobb" <superbiskit AT home DOT com>,
Cygwin General MailList <cygwin AT cygwin DOT com>
From: Randall R Schulz <rschulz AT teknowledge DOT com>
Subject: Re: Console width
In-Reply-To: <3A9FAF05.58FED645@home.com>
Mime-Version: 1.0

David,

The typical reason for this is that your prompt contains characters that 
don't directly render onto the line. BASH (well, the readline library it 
uses) keeps track of where the cursor is on the line (whose length it knows 
via the tty driver) so it can wrap the input. If the output from the shell 
prompt string contains, say, 18 bytes but ends up moving the cursor only 8 
spaces from the left margin, then readline will thing the cursor is 10 
bytes further to the right than it really is and will prematurely wrap the 
line as you type.

The BASH prompt printer allows you to delimit portions of the prompt string 
that do not directly produce characters on the screen and prevents this 
mismatch from occurring.

Check out section 7.10, "Controlling the Prompt" in the BASH manual. Here's 
the part you'll care most about (assuming my diagnosis is correct):

\[      begin a sequence of non-printing characters. This could be used to 
embed a terminal control sequence into he prompt.

\]      end a sequence of non-printing characters.

Here's my prompt. It puts my login name and the current working directory 
in the window title bar and little more than the current command number in 
the actual in-window prompt:


# Prompt -- Host name and current directory in window title bar
if [    "$TERM" = xterm         \
     -o  "$TERM" = xterm-color   \
     -o  "$TERM" = vt100         \
     -o  "$TERM" = vt102         \
     -o  "$TERM" = vt220         \
     -o  "$TERM" = cygwin        \
     ]
then
     PS1=$'\[\e]0; \u :: \W (\w)\a\]\!> '
else
     PS1='\!> '
fi

Since I learned about \[ and \] I've never had the problem you mentioned, 
but I did before.

Randall Schulz
Teknowledge Corp.
Palo Alto, CA USA


At 06:32 3/2/2001, David A. Cobb wrote:
>In my (fullscreen) bash window, the input lines suddenly wrap at about
>3/4 the width of the screen.  Is this a termcap entry, if so how do I
>change it?
>Output lines are fine, they go full width!
>
>
>--
>David A. Cobb


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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