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 use screen in a Ubuntu server.

I have my screen splited in four regions each showing a different window.

The problem is when i detach (or maybe reattach) a get the four windows but only one region and i have to make C-a S all over again?

How can i keep my screen splitted when a reattach?

share|improve this question

5 Answers 5

up vote 10 down vote accepted

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
share|improve this answer
1  
Having spent the past year or two configuring and heavily using nested screen sessions, I recommend it. Over time, the pain of added complexity decreases, while the usefulness of the more flexible setup increases. –  funroll Aug 30 '12 at 18:51
4  
The new feature, i.e., layout, invalidates this answer! –  Kadir Nov 19 '13 at 14:21

I found that if you already have some windows set up and you want to save them you can do this:

Ctrl-a
:
layout save default

Then when you detach and re-attach to the session the layout should be restored.

Works with Screen version 4.00.03jw4 (FAU) 2-May-06 (Ubuntu 12.04 & 12.10)

Also you may want to create a deamon session as such:

$> screen -dmSU mysession

and then have it always available by calling:

$> screen -r mysession
share|improve this answer

In git version, new feature layout was introduced.

from screen(1):

layout new [title]

Create a new layout. The screen will change to one whole region and be switched to the blank window. From here, you build the regions and the windows they show as you desire. The new layout will be numbered with the smallest available integer, starting with zero. You can optionally give a title to your new layout. Otherwise, it will have a default title of "layout". You can always change the title later by using the command layout title.

even if you detached screen session, layout has remember how region was split.

for example, screen start with follow configuration.

layout new
split
split -v
screen 0
focus next
screen 1
focus bottom
screen 2
detach

And reattach this session, you will able to come back into (last selected) layout which has 3 splitted region.

share|improve this answer
    
anyone knows what submissions are required to get this (i'n nerdy enough to apply patches but i will never run trunk code(have bad karma :P)) –  borrel Aug 23 '12 at 7:05

It seems that tmux does. This is a new multiplexer project, inspired by screen, but coded from scratch and under a BSD license.

(Sorry if my English is uncomfortable to read :-°)

share|improve this answer

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.

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.