203
74
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.
203
74
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.
306
C-a :sessionname mySessionName
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.
$ 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. $
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.
$
65
If there are several sessions, use:
screen -S 8890.foo -X sessionname bar
get the actual session name with screen -ls
as mentioned in the other answers – swiesend – 2019-02-13T03:39:23.003
This is a much better answer, which is clear and simple. Thank you so much. – Mars Lee – 2019-04-02T13:45:35.023
8This is a better answer than the one above because it deals with the general case of multiple sessions – doon – 2013-05-21T17:21:07.727
2This is the best answer – Coc – 2013-12-03T10:18:08.453
10
This renames the current window title within a session, as displayed in the window list when you press Ctrl - a+":
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.
5I think the question was about renaming the session, but this answer renames windows. – Dan Gravell – 2014-09-09T09:48:21.127
Duplicate of http://stackoverflow.com/questions/3202111/set-a-name-for-screens-with-the-screen-command
– l0b0 – 2012-08-09T08:00:58.56315@l0b0 That's about naming. This is about renaming. – marcog – 2012-08-09T18:06:38.010