Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh command line scrolls

Status
Not open for further replies.

michaelvv

MIS
Jan 17, 2003
70
US
When using ksh, the command line scrolls to the left after about 76 characters. Since the current directory is part of the prompt, the longer the current directory, the fewer characters of the command I am typing I can see. My terminal type is xterm. Any suggestions are welcome!
 
If you set the COLUMNS variable to the number of columns in your xterm then it should happen closer to the edge of your terminal instead of after 76 chars or so.

Unfortunately ksh doesn't seem to pick this up from the stty settings, or adjust it when the window size is changed (no SIGWINCH handler perhaps?).

Strangely on HP-UX it *does* seem to adjust automatically; shame this feature isn't more widespread.

As a workaround I have this in my .profile. Of course if you change the terminal size after logging in it will not be adjusted:

Code:
export COLUMNS=$(stty -a | sed -n '/columns/{s/.*columns[ =]*\([0-9]*\).*/\1/;p;}')

Annihilannic.
 
Which leads me to ask myself, why not just handle that signal:

Code:
trap 'COLUMNS=$(stty -a | sed -n '\''/columns/{s/.*columns[ =]*\([0-9]*\).*/\1/;p;}'\'')' 28

That seems to work pretty nicely!

Annihilannic.
 
Thanks, this is perfect. In fact, I have set COLUMNS to 255, and it mimics the AIX behavior, by folding the line at the right edge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top