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.
-
16@l0b0 That's about naming. This is about renaming. – moinudin Aug 09 '12 at 18:06
3 Answers
Summary
C-a :sessionname mySessionName
Details
This is,
Attach to the session in question.
Press Ctrl+A.
Type
:sessionname mySessionName– yes, the first colon is needed there, no extra spaces.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 -r
Ctrl+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.
$
- 7,678
- 22
- 41
- 87
If there are several sessions, use:
screen -S 8890.foo -X sessionname bar
- 86,445
- 63
- 260
- 306
- 1,206
- 1
- 9
- 2
-
9This is a better answer than the one above because it deals with the general case of multiple sessions – doon May 21 '13 at 17:21
-
2
-
2get the actual session name with `screen -ls` as mentioned in the other answers – swiesend Feb 13 '19 at 03:39
-
This is a much better answer, which is clear and simple. Thank you so much. – Mars Lee Apr 02 '19 at 13:45
-
use -R is better to find the full default session name rather than -S (type manually) – dtlam26 Oct 25 '21 at 07:59
-
1For people having trouble parsing the command, it is `screen -S
-X sessionname – Konstantin Tarashchanskiy Feb 03 '23 at 18:27`
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.
- 7,456
- 6
- 54
- 56
-
6I think the question was about renaming the _session_, but this answer renames _windows_. – Dan Gravell Sep 09 '14 at 09:48