Is it possible to run a gnu screen within a gnu screen? I'm not sure how the key bindings would work. I need to log into a server that is already running a screen session, from a local screen session.
5 Answers
You just hit ctrl-a followed by an a to actually send the ctrl-a to the nested screen instance.
- 7,926
Yes, it is possible. You will need to redefine screen's escape character, e.g. set it to Ctrl+E when you call screen
screen -e^Eq
- 16,213
-
this is a better answer, and what i was looking for. i wanted to just know how to configure it properly, NOT how to workaround. Why press more keys that you have to, rebind it on teh nest so you know which screen your controlling for sure. – Brian Thomas Mar 22 '16 at 21:11
If you clear the $STY environment variable, running screen will start a nested session.
You then have to send a literal ^a to the nested session before using any of your bindings. You can send a literla ^a by pressing ^a followed by a (plain).
So to create a new window in the nested session you would press ^a, a, c.
- 695
'Ctrl-a a' sends a ctrl-a to the nested screen.
eg, if you want to add a new tab, you do 'ctrl-a a c'
if you want to disconnect: 'ctrl-a a d'
- 573
The commands work fine if you use ctrl-a a or change the escape character. However, he also asked how to attach from inside another terminal. It took me a while to find this online, but after I saw the -m flag I looked it up in the manual.
-m cause screen to ignore the $STY environment variable. With
"screen -m" creation of a new session is enforced, regardless whether screen is
called from within another screen session or not. This flag has a special
meaning in connection with the `-d' option:
-d -m Start screen in "detached" mode. This creates a new session but
doesn't attach to it. This is useful for system startup scripts.
-D -m This also starts screen in "detached" mode, but doesn't fork a new
process. The command exits if the session terminates.
After that I tested creating a new screen with
screen-d -m
and the attaching to it from within screen with
screen -R -D
and it worked the way I wanted, creating a new screen and attaching to it from withing screen. I don't think many people will use this functionality, but sometimes I run out of terminals so it may be useful to have grouped tabs in a seperate screen.
- 11
- 1
-
The selected answer do not explain it well, but for whatever reason I was not able to create the nested screens. So
screen -mwas really useful for me. Thanks for the in-depth startup process. – Irae Carvalho May 08 '21 at 13:20
ctrl-g g 2selects window 2 in the nested screen,ctrl-g 1selects window 1 in the initial screen. – jaygooby Mar 10 '14 at 12:10stuffor equivalent? – sunknudsen Apr 20 '21 at 19:29