In this short tutorial, we’ll explore how to add a vertical split in a region in a GNU screen session.
2. Splitting Vertically
The ability to add a vertical split in a screen region was added in 4.0.1. We can verify our screen version at the command prompt with this:
$ screen -v
Now, let’s go through a few different ways to add a vertical split.
First, let’s start a screen session in a Linux terminal window:
Now, let’s add a vertical split using the following key bindings:
Note the second character is a pipe character. Our current region is now split into two.
We can also split using the colon prompt. First, let’s bring up the colon prompt by typing:
Now, at the prompt, to split the region, we can type:
We now have a vertically split region:
The new region does not have anything in it yet.
3. Switching Regions
Now that we have two regions, we can move to the other region by typing:
Note there is no prompt in the new region, so we need to activate it. Let’s type the following to create a new prompt:
Now, we have two screen regions, each with their own command prompt. We can see the list by typing:
The display should show both windows, e.g.:
To solidify the concept of a new region, let’s switch back to the original prompt in the new region by typing:
Now let’s type some command, e.g.:
This should now show up in both our left and right regions since both regions are showing the same screen window:
We can remove our split region by typing:
Now, we should be in our original full-terminal region. While this command closes the region, any screen windows we created while in that region will still exist. Let’s double-check this by listing our windows with CTRL+a “:
Num Name Flags 0 cloudshell-user@:~ $ 1 cloudshell-user@:~ $
In order to actually kill a window, we can use:
5. Default Setup Using .screenrc
We can also set up some default vertical splitting by adding commands to our .screenrc file. In the user home directory, let’s create or open the .screenrc file using vi:
cd ~ && vi .screenrc
Now, let’s add commands to split the window into two regions and activate the second region. Type i to enter insert mode and then add:
Now let’s save our .screenrc file and exit vi:
Now, next time we start screen at the command line, we will have two regions split vertically.
In this article, we walked through how to set up vertically split regions in GNU.