How to Display Window Tabs in Linux Screen

screen is a Linux program that allows users to create and manage multiple terminal instances. Using tabs to visually track multiple terminal windows is very convenient and luckily not too hard to do.

Screen Window Tabs Example

Here is an example of how to display window tabs in Linux screen. Simply add the below line to the .screenrc file in your home directory, or enter it as a screen command by pressing Ctrl-a + : and pasting it.

caption always "%{= kw}%-w%{= gW}%n %t%{-}%+w %-= - %Y-%m-%d %C:%s"

linux screen window tabs

You can see in the example above that there are 4 open terminals, with the user currently on the third (number 2).

Window Tabs Command Explained

This example command to display open screen terminals as tabs can be confusing. Here are the pieces of that command broken down with descriptions:

caption always – The caption command controls the display of window captions (as a line at the bottom of the screen)
%{= kw} – Clear all current attributes, set background to black, text to white
%-w – Display all window numbers and names up until the current window
%{= gW} – Set current window attributes, set background to green, set text to bright white
%n – Add number to current window
%t – Add name to current window
%{-} – Undoes the last attributes change
%-= – Set padding of caption string to fill terminal width – Example of using custom text
%Y-%m-%d %C:%s – Display the current date and time

screen uses “String Escapes” as a mechanism to display information such as date, time, host, window, etc. Visit these links for more information on captions and string escapes.

Navigating Tabs in Linux Screen

Creating new terminals/tabs in Linux screen can be done with Ctrl-a + c. To navigate to the previous window use Ctrl-a + p. To navigate to the next window use Ctrl-a + n. A list of other useful screen key bindings can be found at screen key bindings.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">