问题
I'm writing a script which needs the name of the currently attached screen session's name if there's any.
回答1:
You might want to check answers here: How do I display the current "session" name or "sockname" of a screen session in the status bar?
In short the $STY environment variable is what you are looking for.
来源:https://stackoverflow.com/questions/16848940/how-can-i-get-currently-attached-screen-session-name