How to split the terminal into more than one "view"?

From vi, if you issue the command :sp, the screen splits into two “views”, allowing you to edit more than one file from the same terminal.

Along those same lines, is there a way to have multiple shells open in the same terminal?

Asked By: Justin Ethier

||

You can do it in screen the terminal multiplexer.

  • To split vertically: ctrla then |.
  • To split horizontally: ctrla then S (uppercase ‘s’).
  • To unsplit: ctrla then Q (uppercase ‘q’).
  • To switch from one to the other: ctrla then tab

Note: After splitting, you need to go into the new region and start a new session via ctrla then c before you can use that area.

EDIT, basic screen usage:

  • New terminal: ctrla then c.
  • Next terminal: ctrla then space.
  • Previous terminal: ctrla then backspace.
  • N’th terminal ctrla then [n]. (works for n∈{0,1…9})
  • Switch between terminals using list: ctrla then " (useful when more than 10 terminals)
  • Send ctrla to the underlying terminal ctrla then a.
Answered By: shellholic

If you want a program that just splits a terminal¹, there’s splitvt. There are programs that split a terminal and do a lot of other stuff besides, such as Screen, Tmux, Emacs, …

¹
It’s the terminal you’re splitting, not the shell.

As mentioned in the comments, besides screen, another good terminal multiplexer is tmux. You can refer to the manual for a complete description and command reference. Some basic operations to get started are:

  • Split screen vertically: Ctrlb and Shift5
  • Split screen horizontally: Ctrlb and Shift"
  • Toggle between panes: Ctrlb and o
  • Close current pane: Ctrlb and x

You can achieve more complex layouts by splitting panes. You can also have multiple windows with panes and switch between them.

  • Create windows: Ctrlb and c
  • Switch to next window: Ctrlb and n
  • Switch to previous window: Ctrlb and p
  • Destroy current window: Ctrlb and Shift7
Answered By: dkaragasidis

Apart from the excellent suggestions on Screen and Tmux if you are using some sort of window manager you may be interested in Terminator you can split horizontally or vertically fashions, plus tabs and more… here’s a list of features taken from the author’s web site:

  • Arrange terminals in a grid
  • Tabs
  • Drag and drop re-ordering of terminals
  • Lots of keyboard shortcuts
  • Save multiple layouts and profiles via GUI preferences editor
  • Simultaneous typing to arbitrary groups of terminals

Have a look to the screenshots on the project site.

Most important you can combine Terminator with Screen/Tmux.

Answered By: alemani

Try tmux (Terminal MUltipleXer):

tmux screenshot

And to understand the difference between session, window and pane:
tmuxnestings

Answered By: Yonatan Maman

Try Vertical Split for GNU Screen

This patch provides a vertical split feature for current releases of GNU Screen. The feature is designed to function in the same manner as screen’s existing split command, but dividing the regions vertically instead of horizontally. Both forms of splits can be used together in any combination/quantity/order desired. Something similar is slated to appear in GNU Screen 4.1 soon, and is already available in CVS per this mailing list thread (and has been included in the Debian and Ubuntu screen packages starting with 4.0.3-10). Also, a recent project named ScreenWM is designed specifically to work with a vsplit-patched screen (check it out!).

Answered By: Narga

Use terminator.

Should be available via your favourite package manager, if you use a mainstream distribution.

It is the only terminal multiplexer where copy-pasting works properly from within panes in your window.

Update: tilix is a terminator alternative which is almost completely on par with terminator (and where copypasting works properly, too). After evaluating it I still stick with terminator however due to nicer tab handling and easier configuration (from my POV).

Answered By: sjas

Konsole for KDE has a built in function:

  • Ctrl+( to Split View Left/Right

  • Ctrl+) to Split View Top/Bottom

  • Shift+Tab will cycle through the split views

  • Shift+Left Arrow/Right Arrow will cycle the current view through the tabs/views

  • Ctrl+Shift+X to close the current view

Answered By: MrUser

Guake + Byobu

Here I wrote a more complete answer.

I’m a happy user of Guake with Byobu inside it, which by default uses tmux (probably better than screen) as backend.

Three steps

  1. Install them (no PPAs needed on Ubuntu/Debian, check for other distros)

     sudo apt install guake byobu
    
  2. Add it to available shells (as told in this Guake Github issue):

     which byobu | sudo tee -a /etc/shells
    
  3. On Guake preferences (guake-prefs) choose Byobu as the default interpreter:

    screenshot

Optionals

  1. Guake

    1. Uncheck "Show tab bar", since you will use Byobu for that:
      image
    2. If a shortcut doesn’t work try disabling Guake ones that might interfere (in my case was Ctrl+F2 for vertical split):
      screenshot
  2. Byobu

    1. Learn shortcuts with Shift+F1 or this excellent screencast.
    2. Learn available byobu terminal commands with apropos byobu
    3. To use Fn keys on Midnight Commander use Alt+ ,or Shift+F12 to disable byobu F-keys.

screenshot

  • For even more happiness use zsh with oh-my-zsh and
  • Test your terminal setup with this test drive (pretty bad for alacritty 🙁 ).
  • I changed local byobu/tmux escape sequence (F9) to Ctrl + h so it doesn’t interfere with tmux on a remote server.
Answered By: Pablo A

Vim can also be used as a rough terminal multiplexer:

:terminal opens a horizontial split terminal,
:vertical terminal opens a vertical split terminal.

As always the commands can be assigned to keyboard shortcuts.

Answered By: Krackout
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.