[ This can be considered step 2 of my previous question Is it possible
to change GNU
screen session name after created? ]
Actually, I'd like
to write a script that can display current
screen session name and
change current session name.
For example:
sren armcross
It will
change the session name
to armcross (ARM gcc cross compiler) and output something like:
screen session name changed from '25278.pts-15.linux-ic37'
to 'armcross'
So,
the key question now is
how to get current session name. Not only for display
the old session name, but according
to Is it possible
to change GNU
screen session name after created? , I have
to know it(pass
to -d -r) before I can
change it
to something else.
Can we use $STY for current session name? No. $STY will not
change after you have changed
the session name
to a user-defined one. However, for command
screen -d -r <oldsessname> -X sessionname armcross
should be the user-defined name(if ever defined) instead of $STY, otherwise, screen spouts error "No screen session found."
Maybe, there is a verbose way, use screen -list to list all sessions(user-defined name listed), then, match the pid part from $STY against those listed sessions and we will find current session's user-defined name. It should not be so verbose for such a straightforward question. Don't you think so?
The -d -D and -r -R options seems to expose too much implementation detail to screen's user. It seems, to rename a session, you have to detach it, then do the rename, then reattach it. Right?
My env: opensuse 11.3, GNU screen 4.00.03 (FAU) 23-Oct-06
Thank you.