In bash I can start a named screen by doing
screen -S test
If I type
ctrl-a A new_screen_name
it only changes the title of the screen. When I do a
screen -r
I see the session name is still the same.
From info screen
:
-- Command: sessionname [NAME]
(none)
Rename the current session. Note that forscreen -list' the name shows up with the process-id prepended. If the argument NAME is omitted, the name of this session is displayed. _Caution_: Among other problems, the
$STY' environment variable still reflects the old name. Use of this command is strongly discouraged. Use the `-S' commandline option if you need this feature. The default is constructed from the tty and host names.
You can change the name of an existing session by attaching to the desired session and once inside issuing a shortcut combination and then a command:
CTRL-A
:sessionname NEW_NAME
If not sure how to do it, below are detailed steps.
First, look for your session ID number:
$ screen -ls
There is a screen on:
7934.pts-1.myserver (01/14/2014 11:27:25 PM) (Detached)
1 Socket in /var/run/screen/S-user.
Then attach to your session:
$ screen -r 7934
Press this shorcut combination:
CTRL-A
Now type this command:
:sessionname MYTEST
Of course, change MYTEST for your desired session name. Press enter to perform the change.
Confirm that your session name has changed:
$ screen -ls
There is a screen on:
7934.MYTEST (01/14/2014 11:27:25 PM) (Detached)
1 Socket in /var/run/screen/S-user.
Congratulations!
Choosing a session name when you are creating it for the first time is even simpler. Just use the screen command with -S option followed by the desired name.
Example:
$ screen -S MY_NEW_SESSION
Confirm the name is assigned:
$ screen -ls
There are screens on:
15832.MY_NEW_SESSION (01/16/2014 10:08:31 AM) (Detached)
1 Socket in /var/run/screen/S-user.
That's it!