This question already has an answer here:
I have this recurring problem when I use
screen with a USB-TTL cable to connect to a serial console (embedded linux device.) I can't seem to configure screen to handle my terminal height correctly. Pager apps like
vim display in weird ways as soon as I start to scroll up.
I've tried numerous
termcap settings in my .screenrc to no avail. I wonder if this has to do with
TERM being set to
vt102 instead of something like
TERM for the logged-in session does not seem to help.
Example screenshot below. Note the footer appears in the middle of the screen with duplicated output.
^L fixes it until the next time I scroll up again.
I'm on OSX using Mac's builtin Terminal.app.
Also, if I SSH into the same box everything works great. In this case
TERM=xterm-256color but of course I am not using
screen anymore either.
EDIT: regarding this being marked as a dupe: I tried the answers in the linked post, with the following result:
resize gives me the following statusline message:
resize: need more than one region.
As to manually setting the height, that's maybe a fine answer for the linked article but but I don't feel like it satisfies the request of how to do this automatically when the session is opened. I updated this post title to clarify.
Edit #2 (with solution)
This answer actually provides a working and automate-able solution. Seems I can't post an answer since this was flagged as a dupe.