Because of some server issues I ended up with two screen sessions, each with a few windows. I have long-running tasks in both sessions and don’t want to abort one of them just to get rid of one of the screen sessions.

Is it possible to concatenate screen sessions so that I end up with a single screen session that contains all windows from both sessions? Or is is possible to manually transfer individual windows from one screen session to another one?


As far as I am aware, this is not possible using screen, but you could use reptyr to reassign the program to a new terminal.

Here is some useful guidance on using reptyr:

You could also look at using the slightly less complex grab.c.

| improve this answer | |

As already answered, there isn't a way with screen alone.

You can also rebind one session's escape character, and therefore have full functionality again (without the need to open another ssh session to your server and detaching one of your sessions - kind of cryptic, I know).

Hit Ctrl-A : which will put you into command mode (if you haven't changed the defaults) and put the following: escape ^Tt. This will change the escape character of one session setting it to Ctrl-T and leaving the other session with Ctrl-A escape char, thus, being able to send commands again to both sessions.

| improve this answer | |
  • 2
    No need to rebind: "C-a a (meta) Send the command character (C-a) to window. See escape command.". So in the "sub-screen" use C-a a, instead of bare C-a. I use it every day. – enzotib Sep 27 '11 at 3:36
  • @enzotib: That is not what I meant. You are talking about readline bindings (Ctrl-a goes to the beginning of the line) and I about screen escape character. If you have two sessions, one inside the other, and both sessions have the same screen-escape-character, who grabs it (i.e. Ctrl-a C for creating another window), the inner most or the outer most ? That is why, when you want to run a screen inside a screen, you have to change one's screen-escape-character. – Torian Sep 27 '11 at 3:55
  • 1
    it is exactly what I mean: C-a + c create a window in the outer screen, and C-a + a + c create a window in the inner screen. So to send a C-a + Something to the inner screen you can do C-a + a + Something – enzotib Sep 27 '11 at 6:41
  • hu, that's nice, didn't know about it :). Either way I prefer rebinding the escape command, it's clearer to me. – Torian Sep 27 '11 at 10:46

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.