Skip

How to get a screen session to work the way I want to?
November 5, 2006 9:17 AM   Subscribe

How do I get my Linux shell to behave the same when I am using screen, as when I am not using it?

I connect to my linux servers with Putty, from Windows. These are two different servers, but I have the same annoyance. When I work in the shell (bash) without using screen, and I use "less" or "man" or "vim" or something like that to read a file, and I close that file, the open file remains visible in the window. I just start typing new stuff below it. If I do not use screen, when I close the file, I get returned to the shell window I was using before, and I can see my previous commands.

Also, when I am not in a screen session, I can use the scrollbars in Putty to scroll up in history. When I am in a screen session, this does not work. I can imagine this is a limitation of screen sessions, but if there is a solution for this, I would like to know as well.

The latter annoyance is not as important, but the former has been irritating me for a long while now, and I hope there is an easy solution.
posted by davar to Computers & Internet (11 answers total) 3 users marked this as a favorite
 
Also, when I am not in a screen session, I can use the scrollbars in Putty to scroll up in history. When I am in a screen session, this does not work. I can imagine this is a limitation of screen sessions, but if there is a solution for this, I would like to know as well.

screen has a built-in scrollback buffer, which you can use by hitting C-a ESC, and then using C-b and C-f to go backwards and forwards.

It's not as convenient as your terminal's scroll bar, but since screen is sort of simulating a terminal inside a terminal, your terminal isn't aware of the rest of the output, and you have to use screen's scrolling (AFAIK).
posted by chrismear at 9:25 AM on November 5, 2006


Change $TERM to whatever it is when you're not running screen.
posted by kcm at 9:29 AM on November 5, 2006


Thanks chrismear, that works! It is a bit more cumbersome than using scrollbars, but now at least I can see the info I want again.

kcm, when I am not in screen, my $TERM is xterm. When I set TERM=xterm inside screen, the behaviour does not change.

Any more ideas?
posted by davar at 10:54 AM on November 5, 2006


dtach + Poderosa? Or any other tabbed terminal. How much of screen's functionality do you really need? When it sounds like you're just using it to maintain a detached process?
posted by mnology at 11:13 AM on November 5, 2006


Try a few other terminals. $TERM=rxvt works much better in alot of situations.
posted by effugas at 11:47 AM on November 5, 2006


export TERM=xterm-noalt
posted by majick at 12:36 PM on November 5, 2006


Aha! Point 2 has bothered me forever, and now a quick search came up with this FAQ that answers the problem!

Just add

termcapinfo xterm ti@:te@

to your ~/.screenrc file, where "xterm" is your $TERM. It fixed both scrollback and leaves less/vim/whatever text there after you exit them.

Of course, I want point 2 without point 1... *grumble grumble*
posted by easyasy3k at 12:56 PM on November 5, 2006 [1 favorite]


Thanks mnology, that is a great solution! I had never heard of Poderosa; it seems very nice.

I tried all the TERM settings, but none did what I want. Maybe it is because I was using Putty, instead of a linux terminal app? With xterm-noalt I get a warning that "WARNING: terminal is not fully functional" when using less, and the problem is still there. When using rxvt the vim/less/man info does disappear when I quit the program, but my screen is totally empty: no history of my previous commands. So, that's not exactly what I was looking for as well.

easyasy3k: Thanks, that is really useful. I will read that page more carefully or try the mailinglist if Poderosa doesn't work out. The solution you quote does not work for me though. I do not want it to leave the vim text after I quite the program.
posted by davar at 1:34 PM on November 5, 2006


If you want screen to clear the text when exiting 'visual' programs, add altscreen on to your ~/.screenrc.
posted by bpt at 2:23 AM on November 7, 2006


Thanks bpt! That does exactly what I want. This has been irritating me for ages.
posted by davar at 6:56 AM on November 7, 2006


"I do not want it to leave the vim text after I quite the program."

I misunderstood the question, then. (Mostly because I can't imagine why an altscreen is at all ever desirable; when I quit less, I want to see the page I quit on so I can type commands while referring to it. I guess I projected my own requirements onto your question.)

I rescind my answer and offer my apologies for muddying the waters and wasting your time.
posted by majick at 9:06 PM on November 9, 2006


« Older Next Monday I'm driving my fri...   |  How do syndication fees for TV... Newer »
This thread is closed to new comments.


Post