image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old August 13th, 2004, 06:07 PM
Registered User
 
Join Date: Apr 2001
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
genecutl is on a distinguished road
Line wrapping in terminal

One thing that bugs me all the time which I haven't been able to figure out is buggy line wrapping in console windows such as Terminal. This is not a Terminal-specific issue, it happens pretty much all over, including XTerm. When I type in a long line, instead of wrapping over to the next line, the text wraps back to the front of the current line overwriting it so that I don't know what the hell I've typed.

Does anyone know how to fix this? It bugs me to no end!
Thanks.
Reply With Quote
  #2  
Old August 16th, 2004, 12:00 PM
michaelsanford's Avatar
Psycholinguist
 
Join Date: Oct 2002
Location: Ottawa/Montrιal
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
michaelsanford is on a distinguished road
Doesn't do that to me. What shell are you using (I'm using tcsh) ?
__________________
michaelsanford.com • Blog • Twitter • Tumblr • LinkedIn
• iMac Aluminum 24" |
MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD
• iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD
• AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2•120 GB RAID 1, 2•500 GB RAID 0
Reply With Quote
  #3  
Old August 16th, 2004, 03:29 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
I found it did that if I used certain escape sequences - if I made my prompt bold, in particular, it alwayst happened. I changed my prompt to leave out the bold part, and it worked ok for the most part.

Another thing I find is that after running some commands that use up the whole screen (curses/ncurses based?), and occasionally just after commands with a lot of output, the next command line will start being entered several lines too high, over top of previously typed commands.
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #4  
Old August 23rd, 2004, 11:45 AM
whyre's Avatar
*nix Geek
 
Join Date: May 2004
Location: Florida
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
whyre is on a distinguished road
Argh, I'm now noticing this problem as well. I took off the bold portion of my prompt, and I still get wrap around, currentky, here's my current .bash_profile:
Code:
GREEN="\e[0;32m"
BLUE="\e[0;34m"
PLAIN="\e[m"
PS1="${GREEN}\u@\h ${BLUE}\W $ ${PLAIN}"
alias ls='ls -GF'
alias su='su -l'
PATH=$PATH:/usr/local/bin
I'm wondering if it has something to do with the escape sequence I assigned to PLAIN to turn off the coloring?
__________________
OS 10.4.10
PowerBook: G4 1.5Ghz 80Gb 1.5GB Ram Ati-9700 (128Ram) Superdrive
iPod Video 5th gen, black 30GB
AirPort Express with AirTunes
Reply With Quote
  #5  
Old August 23rd, 2004, 12:02 PM
whyre's Avatar
*nix Geek
 
Join Date: May 2004
Location: Florida
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
whyre is on a distinguished road
Fixed!

Okay, did some more research on the whole ANSI escape sequences and here's what I found: UnixGuide
Quote:
Readline, the line editing library that bash uses, does not know
that the terminal escape sequences do not take up space on the
screen. The redisplay code assumes, unless told otherwise, that
each character in the prompt is a `printable' character that
takes up one character position on the screen.

You can use the bash prompt expansion facility (see the PROMPTING
section in the manual page) to tell readline that sequences of
characters in the prompt strings take up no screen space.

Use the \[ escape to begin a sequence of non-printing characters,
and the \] escape to signal the end of such a sequence.
So I've changed my .bash_profile to reflect these changes:

Code:
GREEN="\[\e[0;32m\]"
BLUE="\[\e[0;34m\]"
PLAIN="\[\e[m\]"
PS1="${GREEN}\u@\h ${BLUE}\W $ ${PLAIN}"
alias ls='ls -GF'
alias su='su -l'
PATH=$PATH:/usr/local/bin
...and viola! No more odd wrapping!
__________________
OS 10.4.10
PowerBook: G4 1.5Ghz 80Gb 1.5GB Ram Ati-9700 (128Ram) Superdrive
iPod Video 5th gen, black 30GB
AirPort Express with AirTunes
Reply With Quote
  #6  
Old August 23rd, 2004, 04:52 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
Excellent! Thanks for the tip.

I was using stuff like `tput bold` and `tput sgr0` (for plain text) for escape sequences and having the same sort of problems. Just tried with the backticked stuff like this:
bold='\['`tput bold`'\]'
and line wrapping works fine again!

Anyway I just use tcsh, which is what I got used to from OS X pre-10.3 anyway. Using the predefined sequences %B and %b for bold on/off, it counts printing characters correctly on its own.
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 09:54 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.