How do you know your current gnu screen session

We used the gnu screen a lot in the office, and sometimes, if I don’t take note, I end up getting lost as to which screen session I’m already entering.

So my question is: how do you know which screen session you are on? Do you have a way to check?

ACKNOWLEDGMENT: I ​​need to know when I am doing:

~$ 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 connected to any connected session?

Thanks in advance.

+4
source share
2 answers

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

 $ echo $STY 5521.mysql01 $ 
+6
source

Update:

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

Previous answer (with a question about incomprehensible):

I also struggled with this until I came across the wonderful hardstatus feature. With these two lines in my ~/.screenrc I get the following at the bottom of the 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 see 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 via ssh, on which I start another screen session with three windows ( top , auto , bash ). I see all the windows in both sessions and keep track of where I am.

+4
source

All Articles