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.
You just hit ctrl-a followed by an a to actually send the ctrl-a to the nested screen instance.
3No, as RobM correctly notes, you must type ctrl-a a to send ctrl-a to the nested screen. Jul 11, 2011 at 16:17
18Yo dawg. I heard you like screens, so I put a ctrl-a in your ctrl-a so you can screen while you screen.– user67218Feb 15, 2012 at 17:46
1Also works for remapped codes; my trigger is ctrl-g (because I like ctrl-a to go to the beginning of a line in bash), so in the nested session;
ctrl-g g 2selects window 2 in the nested screen,
ctrl-g 1selects window 1 in the initial screen.– jaygoobyMar 10, 2014 at 12:10
Is there a way to send ctrl-a-a to existing screen session using
stuffor equivalent? Apr 20, 2021 at 19:29
Yes, it is possible. You will need to redefine
screen's escape character, e.g. set it to Ctrl+E when you call
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. Mar 22, 2016 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
So to create a new window in the nested session you would press
'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'
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
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.
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. May 8, 2021 at 13:20