Home » Questions » Computers [ Ask a new question ]

How to keep windows split after detaching/reattaching GNU screen

How to keep windows split after detaching/reattaching GNU screen

I use screen in a Ubuntu server.

Asked by: Guest | Views: 329
Total answers/comments: 3
bert [Entry]

"From the screen FAQ:

(The implied question being, “How do I keep my split windows over a detach?”)

The short is answer is that you can't. The longer answer is that you can fake it.

Splits are a property of your display. The process managing your screen session doesn't
really know about them; only the single process that's displaying the session does.
Thus, the screen session can't remember the splits because it doesn't know about
them, and once you detach, the process that did know about them has exited.

The hack is to use nested screen sessions. Start one session and give it some
escape sequence that you won't use much (or just disable its escape character
completely). Bind your usual detach key sequence to this screen session. Now,
start or attach to your main screen session. All of your work will be done in
the inner session, and you can split your display. When you detach, however, it
will be the outer session that detaches, so your splits in the inner session will
be preserved.

Assuming you use the default escape character, C-a, your alternate screenrc
should contain:

escape """"
bindkey ^ad detach"
bert [Entry]

"Simply add this line to your ~/.screenrc:

# This line makes Detach and Re-attach without losing the regions/windows layout
layout save default"
bert [Entry]

I've read the whole screen man recently, and there's no common way to do it if screen itself can't remember it automatically.
I've read the whole screen man recently, and there's no common way to do it if screen itself can't remember it automatically.