40

I am running a screen session and I'd like to change it's name. I know that when starting a new screen session I can use the '-S' option to give it a name. How do I change that name once the session has already started?

migrated from stackoverflow.com Dec 27 '11 at 23:55

This question came from our site for professional and enthusiast programmers.

52

There is a screen command to do this. From the manual:

Command: sessionname [name]

(none)

Rename the current session. Note that for screen -list the name shows up with the process-id prepended. If the argument name is omitted, the name of this session is displayed.

Caution: The $STY environment variable still reflects the old name. This may result in confusion. The default is constructed from the tty and host names.

To access the screen command line, use Prefix:, where Prefix is typically Ctrl-a.

So you will most likely have to do so: Ctrl-a:sessionname [name]

  • does not work on mac. Do you mean press control + a +: three buttons at once? – Ka-Wa Yip Aug 6 '16 at 19:13
  • 3
    no it means ctrl+a (both buttons at once) followed by ':' – Harry Wood Sep 27 '17 at 15:03
24

To rename the window title within a screen session use:

  • press and release Ctrl+a and then press Shift+a

To rename the actual session name (displayed with screen -ls) use:

  • 3
    It seems this changes the window title but not the name shown in, for example, screen -R or screen -list. – reg Oct 29 '14 at 17:10
  • 4
    As @reg states, this changes the title of the current window as seen in Ctrl-a " - not the screen session as a whole, which was the question asked by the OP. – John Rix Aug 13 '15 at 11:43
  • does not work on mac. Do you mean press control + shift +a? – Ka-Wa Yip Aug 6 '16 at 19:12
  • 2
    @kww it's press Ctrl-a first, then Shift-a. – mitnk Oct 9 '16 at 3:54
  • C+a doesn't help at all, but the link you posted did – machineaddict Nov 7 '18 at 10:29
5
# screen -S old_session_name -X sessionname new_session_name
  • 1
    This didn't work for me on Fedora 29 (Screen version 4.06.02 (GNU) 23-Oct-17), I had to use Ctrl a followed by :sessionname <new-session-name>. It did, however, work on OS X with Screen version 4.00.03 (FAU) 23-Oct-06 – adamc Nov 21 '18 at 23:06
0

May not be answering this exact question, but to change the name displayed at the bottom like (0 bash), you can use

  • Ctrl-a then :title <newtitle> to change the bash part
  • Ctrl-a then :number <newnumber> to change the number (which will also change relative order of your session instances).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.