Home Command line tools How to Change the Title in GNU Screen

How to Change the Title in GNU Screen

by The Linux Digest Guy
Screen: Change the Title

If you are an experienced Linux user, chances are you have used GNU screen at some point. GNU screen is a powerful terminal multiplexer that enables you to create multiple virtual terminals within a single window. An added benefit is that you can exit your terminal session and come back to it as you left it.

I find that once I have more than one window or region in my screen session, it becomes important to organize my terminal. That’s where window titles come in handy. You can name each window according to the task that is being performed.

In this article, I will show you how you can, name the window and browse windows by their titles. And at the end, I will show you how you can also name your sessions in case you are running more than one session.

How do you change the title in GNU screen?

To change the name of a window or a region in GNU screen, all you need to do is hit Ctrl-a A. Once you do that, a prompt will appear at the bottom of the screen. There you can write the new name and hit enter to apply it.

In case you are unfamiliar with screen key bindings: Ctrl-a A means that you will press the Ctrl key and a simultaneously. Release them and then hit SHIFT and a for an upper case A. This key sequence is often written as C-a A in GNU screen documentation.

The window should now have a new title. If it is not visible in your configuration, you can hit Ctrl-a N to display the current title.

Browse windows by name.

You can list all the current windows with Ctrl-a “. This will bring up a list of the currently open windows and you can select a window using your arrow keys.

Set the window title at startup

You can set the window’s title before entering the screen by passing it the -t option. If the name contains spaces, you will have to wrap it in quotes.

screen -t "My new window"

How do you change the name of a screen session?

When you have multiple sessions of screen running, each of them will have a name similar to this:

linuxdigest@linuxdigest:~$ screen -ls
There are screens on:
	1695.pts-3.linuxdigest	(03/05/23 00:54:10)	(Attached)
	1554.console.linuxdigest	(03/05/23 00:50:59)	(Attached)
2 Sockets in /run/screen/S-linuxdigest.

These names are constructed of the process ID, TTY, and hostname. If you have more than one session, remembering which session is which will start to get confusing.

You can change the name of the session you are in by evoking the command mode with Ctrl-a : and issuing the command sessionname, like so:

:sessionname myName

Once you have done this, the session names will hopefully be easier to distinguish:

linuxdigest@linuxdigest:~$ screen -ls
There are screens on:
	1695.myName	(03/05/23 00:54:10)	(Detached)
	1554.logViewer	(03/05/23 00:50:59)	(Detached)
2 Sockets in /run/screen/S-linuxdigest.

Set the session name when starting screen

Of course, you can also set the session name when you start a new screen session. This is done with the -S option. If you want to name the session ScreenTutorial, you will have to write the following on the command line:

screen -S ScreenTutorial

Now when you list the running sessions with screen -ls or screen -list, you will see something like this:

linuxdigest@linuxdigest:~$ screen -list
There is a screen on:
        1816.ScreenTutorial     (03/05/23 06:12:53)     (Attached)
1 Socket in /run/screen/S-linuxdigest.

Thats it! Now you should be able to name your windows and sessions like a pro! I hope you found this useful.

1

Related Posts

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy