Steve Lorimer
Steve Lorimer

Reputation: 28659

How can I create a nested screen session?

What do I need to put in my .screenrc so that I can create nested sessions (ie: a screen within a screen)?

At the moment, if I run screen again from within an open screen tab, instead of opening a new screen session within that tab, it just opens a new tab (ie: same effect as if I had pressed -C)

I want to get an outer screen session and an inner screen session - How do I do this please?

My .screenrc is empty except for the following single line to show the list of open tabs:

hardstatus alwayslastline "%{=w}%{G} %{b}%w"

Upvotes: 4

Views: 7085

Answers (4)

Aethalides
Aethalides

Reputation: 407

From what I read in your question, it seems that you may be confused how to operate the nested session?

CTRL+a c will create a new 'tab' in the outer screen session.
CTRL+a a c will create a new 'tab' in the session 1 deeper than the previous
CTRL+a a a c creates a new tab in the session 1 deeper than the previous

I have had situation with 3 layers, where I SSH into my work box, then from there into a proxy and from there onto the server I want to work on, each time opening a screen session to be able to resume later.

Without a hardstatus showing the full hostname, it is very easy to get lost, very easy indeed!

Upvotes: 4

Lewis Diamond
Lewis Diamond

Reputation: 24911

This is a very old question, but for reference:

Start a MAIN screen session:

screen -S main

Start a second session (detached):

screen -dmS SomeName

From the tab you want nested session:

screen -r SomeName

Use and extra a for commands to nested screen, i.e. ^a-a-c to create a tab in the nested screen.

Upvotes: 7

C. Chen
C. Chen

Reputation: 41

Don't know if what you mean is to start some nested sessions from your screenrc or to set something in your screenrc so you can start nested sessions from the colon prompt.

For the first, I use a separate screenrc file, .screenrc.main, which contains

source ~/.screenrc
screen -t <window name> screen -S <nested session name> -e^jj <command>

I think the "new session name" part is necessary to get a new session. I use a different command character for the nested sessions. Also I am using a separate file because I don't want the command to be executed for the nested sessions. Then from command line I do

DISPLAY= screen -S <top session name> -c .screenrc.main

to start the outer session.

For the second, I just type in the screen -t line above in the colon prompt.

Upvotes: 4

Ross Aiken
Ross Aiken

Reputation: 952

I don't know about editing your screenrc file, but what works for me is sshing into the same computer then starting a new screen instance. Hackish workaround, but it does work...

screen
ssh 127.0.0.1
screen

Upvotes: 2

Related Questions