Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm configuring both my gnome-terminal and xterm columns (i still haven't picked which of these I will be using) and I have a couple of issues I would like to fix:

  • the typing area seems to be smaller (fewer columns) than the display area
  • the typed text is not wrapping to the next line when it reaches the end - it just continues back around on the same line, overwriting the prompt

(i have set a custom bash prompt with PS1 in case this is relevant)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.1 (wheezy)
Release:    7.1
Codename:   wheezy
$ echo $TERM
xterm
$ stty -a
[peter@mine ~] $ stty -a
speed 38400 baud; rows 52; columns 126; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
$[peter@mine ~] $ # the column width only goes up to here ------------------------------------------------>

the results are identical in both the xterm and in gnome-terminal 3.4.1.1

and as you can see, the output of the stty -a command goes right up to the edge of the screen, while the typing does not go that far.

I have found that I can get the desired result by setting the columns to a very large number, eg:

$ stty cols 1800

this fixes both problems. Is it the right way to go about solving this problem? Will this "break" any of the output from programs? So far I have tried top and stty -a and these seem OK.

more info as requested in the comments

i found that if i cat some input into a file then the columns actually strech the full width of the terminal window:

[peter@mine applications] $ cat > /tmp/asd
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssssssssssssssssssssssqqqqqqqqqqqqqqqq
qqqq

does this imply that it is actually bash that is restricting the number of columns and not the terminal? if so then how to alter the number of columns in bash?

share|improve this question
1  
Please always mention your operating system. xterm runs on Linux, Unix, BSD, OSX, Solaris, etc etc. Also, are you actually using the xterm terminal emulator? $TERM does not define the emulator being run, only its type. –  terdon Sep 30 '13 at 14:23
    
ok i have added that info. –  mulllhausen Sep 30 '13 at 14:29
    
So, is this actually xterm or another terminal emulator? Also, try removing your custom PS1, do you still have this issue? –  terdon Sep 30 '13 at 14:30
    
And do you have the same problems if you’re typing into something other than bash; e.g., csh or cat (type cat > /tmp/asdfg; end with Ctrl+C or Ctrl+D)? –  Scott Oct 1 '13 at 1:58
    
thanks for the diagnosis suggestions. i will post the results when i get back home later on today. –  mulllhausen Oct 1 '13 at 4:06

2 Answers 2

up vote 2 down vote accepted

It's likely you don't have properly escaped ANSI code in your prompt definition in your ~/.bashrc

For instance, a PS1 something like:

    PS1='\033[1;33m>\033[0m '

... Will wrap badly, before the width of the shell itself.

Placing square brackets before the ascii escape character and after the definition terminator will fix this, resulting in expected wrapping:

    PS1='\[\033[1;33m\]>\[\033[0m\] '      

I.e \033 becomes \[\033 and m becomes m\]

(I learned this myself some time ago here).

share|improve this answer
    
excellent! that worked! i used \e instead of '\033' since both of these are the ascii escape sequence. –  mulllhausen Feb 12 '14 at 5:13

As was already pointed out in the comments, your question--even after "clarifying"--is unclear and "incomplete". For instance, you are still not saying whether you're referring to xterm the Program/Application/Terminal-emulator or the type of terminal (i.e. the value you get when you type $TERM. Regardless, I'll attempt provide an answer--or at least to guide you in the right direction.

Given the fact that you customized your bash prompt, I'm assuming this will be the root of your problem. There's a number of pertinent discussions, references, information on the frequent line-wrap problems users run into after customizing bash. This appears to be, in most cases, an issue with escaping ANSI color codes; some more Q&A's on stackoverflow.

Again, I'm not sure how you did the customization (that stty output doesn't tell me anything), since there a few number of options to achieve this; however, if you did a backup of your default settings and files, that should be your first line of action. Alternatively, you could also try shopt -s checkwinsize to make sure it's selected, or just shopt -p will give you the listing of the bash options that are either -s:selected or -u:unselected. Also, check your manual pages to get an idea about some of these things, especially if it's your login shell.

Finally, try to be a little more specific when asking questions; or even better, do a search before for similar questions that might have been already asked.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.