Moving windows between GNU screen sessions

11

4

Is there a way to move windows between different screen sessions?

For example lets say I have this scenario:

screen -S screen1
vim *.cpp
C-a d
screen -S screen2

Is there any way to move my shell containing my vim session from screen1 to screen2?

William Casarin

Posted 2010-04-10T05:22:23.663

Reputation: 720

1i don't think so, but i'm not much of a screen guru. interesting question, +1. – quack quixote – 2010-04-10T05:54:32.980

2

found a discussion on the screen mailing list - http://lists.gnu.org/archive/html/screen-users/2008-04/msg00009.html - it's not possible at the moment and a 'nightmare' to implement apparently.

– William Casarin – 2010-04-12T16:40:15.613

Answers

4

You can use injcode to move a process between ttys. To move process with PID run in target screen window:

$ injcode -m retty PID

However when you close the parent Screen session, moved processes will also terminate.

Edit: I was wrong, it works. Everything is described here. Suppose you want to move "htop" and only one instance is running:

$ injcode -m retty $(pgrep htop)
$ pkill -SIGSTOP htop
$ pkill -SIGCONT htop

then on the previous shell type:

$ disown

askonecki

Posted 2010-04-10T05:22:23.663

Reputation: 186