icasimpan
icasimpan

Reputation: 1313

how do you know your currently attached gnu screen session

We used gnu screen a lot in the office and sometimes if I don't take note, I end up getting lost as to what screen session I already am in.

So my question is, how do you know what screen session you're in? Do you have a way to check?

CLARIFICATION: What I need to know is when I do a:

~$ screen -ls

and I see something like:

There is a screen on:
    4732.work_Sept42012     (Attached)
    3551.web01  (Attached)
    5521.mysql01 (Attached)
    1255.tomcat05 (Detached)
    3326.oracle15 (Attached)

 1 Socket in /tmp/uscreens/S-icasimpan.

How do I know if I am currently connected to any of the attached session?

Thanks in advance.

Upvotes: 4

Views: 2875

Answers (2)

bonsaiviking
bonsaiviking

Reputation: 5995

In addition to the sessionname screen command, screen sets the STY environment variable for processes it starts. You can check the value of this variable from a shell:

$ echo $STY
5521.mysql01
$

Upvotes: 8

Backlin
Backlin

Reputation: 14842

Update:

ctrl+a, :sessionname can be used to display the name of the current screen session.

Previous reply (with missinterpreted question):

I struggled with this too until I came across the wonderful hardstatus feature. With these two lines in my ~/.screenrc I get the following at the bottom of my screen sessions.

hardstatus alwayslastline
hardstatus string '%{= kG}%-Lw%{= kW}%50> %n*%f %t%{= kG}%+Lw%< %{= kG}%-=%D %M %d | %C:%s %A %1`%{-}'

enter image description here

What I am looking at here is a screen session on my local computer with three windows (bash, mumble, kalkyl). In the active window called mumble I am connected to another computer over ssh on which I am running another screen session with three windows (top, auto, bash). I can see see all windows in both sessions and keep track of where I am.

Upvotes: 4

Related Questions