Rename screen session

Is it possible to change the name of a GNU screen session? Say I called started it with "screen -S foo" and I want to rename it to bar.

1

3 Answers

If there are several sessions, use:

screen -S 8890.foo -X sessionname bar
5

Summary

C-a :sessionname mySessionName

Details

This is,

  1. Attach to the session in question.

  2. Press Ctrl+A.

  3. Type :sessionname mySessionName – yes, the first colon is needed there, no extra spaces.

  4. Type Enter.

Example

$ screen -S foo
[detached from 8890.foo]
$ screen -ls
There is a screen on: 8890.foo (22/12/11 18:39:22) (Detached)
1 Socket in /var/run/screen/S-user.
$ screen -rCtrl+A:sessionname bars
[detached from 8890.bars]
$ screen -ls
There is a screen on: 8890.bars (22/12/11 18:39:21) (Detached)
1 Socket in /var/run/screen/S-user.
$ 

Renaming without attaching

Screen's -X switch lets you rename a session without attaching it.

$ screen -X sessionname foobars
$ screen -ls
There is a screen on: 8890.foobars (22/12/11 18:39:22) (Detached)
1 Socket in /var/run/screen/S-user.
$ 

Alternatively, you can specifically target a screen session by its existing name or id (useful if there are already multiple sessions):

$ screen -ls
There is a screen on: 8890.foo (02/23/2015 18:39:22) (Detached) 5136.barfoos (02/23/2015 18:39:22) (Detached)
1 Socket in /var/run/screen/S-user.
$ screen -S 8890.foo -X sessionname foobars
$ screen -ls
There is a screen on: 8890.foobars (02/23/2015 18:39:22) (Detached) 5136.barfoos (02/23/2015 18:39:22) (Detached)
1 Socket in /var/run/screen/S-user.
$ 
0

This renames the current window title within a session, as displayed in the window list when you press Ctrl - a+":

  • While in a screen session press Ctrl - a + A (it's an uppercase a, i.e.Shift+a), type the new name, and press Enter

Now when you do Ctrl - a+" the name you set will appear in the window list instead of bash.

NOTE: This does not answer the original question, but I am not deleting the answer since apparently some of the visitors to this thread searched for a way to rename the window title, and not the actual session as the OP asked.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like