开发者

gnu screen: reattach all previously detached sessions

开发者 https://www.devze.com 2023-01-01 06:30 出处:网络
I have a few windows in a single screen session and then I want to detach my session. There is no problem with that.

I have a few windows in a single screen session and then I want to detach my session. There is no problem with that.

But I can't find a way to restore all windows within my previously detached session. I can see that I can restore just one of them by ID.

But how can I reattach exact the same session environment with all the windows in it?

--

Updated:

If I type screen -d -r, 开发者_运维知识库this is what is says:

There are several suitable screens on:
    21074.pts-7.atx (05/29/2010 02:26:32 PM)    (Attached)
    3420.pts-3.atx  (05/29/2010 12:16:41 AM)    (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

How can I reattach all of them?


screen -d -r : Reattach a session and if necessary detach it first.

This will reattach your old session, will all its windows. If your session is still attached, it will detach it before attaching it to the current terminal. This is quite useful when for example you have kept your screen session in an ssh terminal on another computer.


To reattach all previously detached sessions I use this little script.

#!/bin/sh
for line in `screen -ls | grep Detached |  awk '{print $1}'`; do
   xdotool key control+shift+t type "screen -r $line"
   xdotool key KP_Enter
done

"control+shift+t" happened to be a shortcut in my terminal for opening a new tab and it may be different shortcut in yours.

0

精彩评论

暂无评论...
验证码 换一张
取 消