This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Console width


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]