I know how to see if I am in a screen: I have made an alias alias inscreen = 'echo $STY' .

But earlier today, I accidently type screen inside a screen without noticing it and in some way it made me make a mistake later.

Things I've observe when I type screen (inner screen) inside a screen (outer screen):

  1. screen -ls only shows 1 result related to that screen
  2. echo $STY is the same in both inner and outer screen
  3. ctrl + A and ctrl + D can detach from the inner screen to no screen, but when screen -r back, both inner screen and out screen exist
  4. now I can exit twice: inner screen exit -> outer screen exit

So my question is, is there anyway I could know I am in a screen of a screen?

P.S. When type screen for the first time, it will pop some text:

enter image description here

if type screen inside a screen, it won't show these hints.

  • Well I just think of a possible solution, when I exit a screen, then screen -ls, if it shows any screen is attached, that mean I was exited from an inner screen just now.
    – Rick
    Commented Jun 7, 2022 at 7:03
  • 1
    The default for screen when run within an existing screen session is to create a new window in that session. Are you running screen -m, or just mistaking a window for a new session? If you don't have a status line configured, maybe set one that shows window details (e.g., hardstatus string '%?%-Lw%?(%n*%f %t%?(%u)%?)') and see if you aren't just seeing windows in action.
    – muru
    Commented Jun 7, 2022 at 7:15
  • @muru ya someone just told me that when I type screen inside a screen, it opens something called "window", not a nested screen.
    – Rick
    Commented Jun 7, 2022 at 7:28

1 Answer 1


From @geirha, a bash guru from libra irc #bash:

if you run ''screen'' inside a screen, you open a new window in that screen. It does not start a nested screen.

so typing screen inside a screen, I am opening new windows.

you can switch between the windows with ctrl+a n and ctrl+a p

also, try ctrl+a :caption always

this would show a status bar indicating which window you are current in.


put caption always "%{ Mk}%-w%{ Wk}%n %t%{ Mk}%+w" in ~/.screenrc

would have a cool status bar every time you enter screen:

enter image description here

(Format specifiers customizing how the caption will look. See STRING ESCAPES in man screen)

Ctrl+a :title "hello world"


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .