92

I saw some body split their window to 2x2, I just want to know how to do that? I know the 'split' command in Screen can only split the window horizontally.

3
  • 4
    This is not possible in some (all?) versions of gnu screen, a custom patch was developed to do this and has been applied in many distributions. I believe this patch is supposed to have made it into upstream, but may not have been released yet. Consider using tmux instead. Commented Dec 13, 2011 at 6:44
  • @math - what do you expect on this Q&A? The A w/ 9 UV's is the right A.
    – slm
    Commented Jan 30, 2014 at 8:10
  • Yes, I though I could promote it to accepted then. As the first with (currently 6) votes is outdated.
    – math
    Commented Jan 30, 2014 at 8:42

5 Answers 5

169
+50

The latest version of GNU screen allows you split the window vertically without any external patches. Here is one way to get it and use it:

  1. Checkout/clone/download the source
  2. Build it in an easy sequence of ./autogen.sh, ./configure, make and install. I didn't have any problems with dependencies on Mountain Lion.
  3. To get a vertical split use:

    C-a |     // Create a split
    C-a <Tab> // Move to the split
    C-a c     // Create a new window within the split
    

I don't think this is a reason to switch to tmux any more like others have been suggesting.

7
  • 3
    Is it possible to preconfigure screen to autostart with multiple splits ? Commented Apr 3, 2013 at 13:41
  • @Fedir Sorry about the late response. But I'm not sure.
    – gkb0986
    Commented May 5, 2013 at 21:16
  • 5
    Sure! You have to add split, split -v and focus commands in the screenrc file. Even you can place screen inside another screen to make complex configurations.
    – Kondybas
    Commented May 27, 2014 at 1:28
  • 5
    @Kellen: When you say "The latest version ..." which version do you mean? I have Screen version 4.00.03 (FAU) 23-Oct-06, but neither C-a | nor split -v work. For example, when I execute the split -v command the error message is split: no arguments required
    – John Prior
    Commented Jan 21, 2015 at 19:30
  • 4
    To unsplit a window again, you can continue reading here: Unix: How to unsplit in screen
    – hakre
    Commented Jul 15, 2015 at 7:23
49

Check out the video tutorial on Split Screen with Screen in Linux - BASH . At time 2:00 minute, there would be a solution.

Ctrl+A, Shift+S # Create another window

Ctrl+A, Tab # Moving from another window

Ctrl+A, c # Create new session

Ctrl+A, | # Splitting vertical (pipe symbol)

Ctrl+A, Shift+S # Splitting horizontal

Ctrl+A, Shift+X # Close a window

1
  • 2
    Note that to close a region it's capital X meaning ctrl-a shift-x. If we do ctrl-a x (small x) it actually causes the screen to lock.
    – Daniel
    Commented Nov 18, 2021 at 11:43
24

GNU Screen <4.01 may not support vertical split without a patch.
GNU Screen >4.01 supports vertical splitting.

The Patch is licensed under GPLv2. Some people say that the vertical split in GNU screen makes the application slow but I haven't tested. I use tmux (terminal multiplexer)

8
  • 24
    Note: This is no longer true. Vertical splits are part of the official source and Ubuntu packages ship with the functionality built in. Commented Feb 20, 2013 at 15:49
  • 1
    @JaredMcAteer, it may be part of the official packages Ubuntu ships with, but the newest release of screen available through the GNU screen project page is 4.00.03, released in 2006. They may have the functionality in their git repo, but it's not part of a release yet as far as I've found. Commented Oct 14, 2013 at 20:58
  • 9
    I hate answers where it's suggested to use another software. +1 for tmux nonetheless.
    – pfnuesel
    Commented Jan 30, 2014 at 1:58
  • 1
    I think stack should take an accepted answer, once ANOTHER answer surpasses it in points, turn the accepted check-mark yellow, then add the green check-mark to the highest voted. This is totally based upon the simple fact, that the GREEN check-mark is supposed to the more realistic figure. However that is not the case. The REALISTIC figure is the one with the HIGHEST VOTES, almost always. I.E. this green check is not the answer, see the highest voted.. Commented Mar 18, 2016 at 23:16
  • Yay, another project that has moved off Sourceforge! edited link.
    – naught101
    Commented May 19, 2016 at 0:20
9

Use the -v option to split command in screen. From the manpage:

   Split  the current region into two new ones. All regions on the display
   are resized to make room for the new region. The blank window  is  dis‐
   played  on  the  new  region. Splits are made horizontally unless -v is
   used. Use the "remove" or the "only" command  to  delete  regions.  Use
   "focus" to toggle between regions.
6
  • Which split command are you referring to? Commented Dec 13, 2011 at 4:54
  • As mentioned, the command in screen.
    – Arcege
    Commented Dec 13, 2011 at 6:10
  • it does not accept arguments. :(
    – Rocky
    Commented Dec 13, 2011 at 7:41
  • 4
    It works here (Ubuntu 11.10), also with shortcur C-a |.
    – enzotib
    Commented Dec 13, 2011 at 8:35
  • 8
    So, in order to input commands in screen, one needs to do C-a : (control a, colon). There you can do split or split -v. C-a | is a shortcut for a vertical split, though.
    – droope
    Commented Jul 7, 2014 at 5:00
3

A WITHOUT using bind-key open way

Since I google out many of videos are telling us to use bind-keys, I tidy up some steps that we can open GNU screen by code...

  1. save the following context to ~/.screenrc or /etc/screenrc or any text file
screen 1 top
split -v
focus right
screen 2 python3 -m http.server 0
split -v
focus right
screen 3 nano .bashrc

Note: change the command top, python3 -m http.server 0, nano .bashrc as you want

  1. run the following command
screen

or

screen -c ~/.screenrc

Note: If your file DID NOT save to ~/.screenrc or /etc/screenrc , the first command would become NOT WORKING.

  1. enjoy your split windows

Note: If the command terminated, the split window will become blank. To solve this problem, you can run exec echo "hello world" instead.

  1. close GNU-screen by Ctrl+A, \

Reference:


Vertically way

screen 1 top
split
focus down
screen 2 python3 -m http.server 0
split
focus down
screen 3 nano .bashrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .