I'm using the default versions of bash and screen in OS X Lion.

When I'm in a screen session and I scroll back through the bash history and I come to a command that is long enough to wrap.

I might first type some command:

selassid@tem02:~$ ls ljmix/fiftyfifty_softsphere/T0.350/r2.43/0.565421311859c0.1

That wraps properly as written above, but if I press up to access it via bash's history, the console displays only:


So the prompt and the entire first line of the command is missing, which makes it difficult to edit; if I scroll back to the first line, it appears but it overwrites the last line of output. When I execute the command, the rest of the first line is displayed and everything looks as expected:

selassid@tem02:~$ ls ljmix/fiftyfifty_softsphere/T0.350/r2.43/0.565421311859c0.1
total 1792

What's more curious, is that if use the history to access the long command but I don't execute it yet, then use any C-a screen command, like switching to another window and then back, or if I click out of my current terminal window and back into it, the history command is now displayed properly again.

My PS1='\u@\h:\w$ ' so there's nothing strange going on there.

Is there a way to correctly show the whole command when using the history? I've tried playing with the screen wrap settings, but they only make things worse.

stty -a shows:

speed 9600 baud; 46 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;
  • Can you do echo $TERM when inside the screen and provide the output? Also, if you run tput am; echo $?, what do you get? – phemmer Dec 1 '11 at 20:05
  • TERM is xterm-256color and tput am; echo $? just gives me 0. – selassid Dec 1 '11 at 22:29
  • Also, this only happens when you're scrolling through the history at the bottom of a window, so all of the text would have to move up to show you the second line of the command in your history. – selassid Dec 2 '11 at 0:21
  • What's the output of stty -a? – Andy Smith Dec 2 '11 at 1:21
  • I've added it to the bottom of the post. It matches what is output when screen isn't running. – selassid Dec 2 '11 at 1:40

Based on the answer to the comment up above, it appears your are overriding TERM in one of your startup scripts. While inside screen, your TERM should be set to 'screen', not 'xterm-256color'.

I would look through your shell startup scripts. ~/.bashrc, /etc/bash/bashrc, and possibly others like ~/.bash_profile and /etc/profile depending on how you have everything set up. If you see any TERM="..." settings, you need to remove those.

  • That was true, but even after removing those, and checking that TERM is "screen" inside of screen still doesn't fix the problem. – selassid Dec 1 '11 at 22:51
  • Do you have a ~/.inputrc or /etc/inputrc? If so, make sure that horizontal-scroll-mode isnt set, or that its set to off. – phemmer Dec 1 '11 at 23:21
  • I do have a ~/.inputrc, but horizontal-scroll-mode isn't set and setting it to off doesn't change the behavior. I have input-meta and output-meta on and convert-meta off, but removing those settings doesn't change the behavior. – selassid Dec 1 '11 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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