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 %-= bigdatums.net - %Y-%m-%d %C:%s"
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 widthbigdatums.net
– 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.
Hello,
Do you know how to put a bash function or a script in the caption or hardstatus ? I’d like to put a session countdown timer in there.