GNU Screen switch from vertical split to horizontal and back

gnu-screen

I'm using a recent version of GNU Screen, supporting vertical splits.

Once I have split a window in 2, how can I switch so that they are both dividing the whole region in half horizontally versus vertical?

I need to change to horizontal in order to copy some text with mouse from one window without the visual selection overflowing and grabbing text from the other window.

Then I would need to switch back again to a vertical split from horizontal.

Best Answer

GNU screen doesn't come with any layouts predefined, so you need to roll your own. Here is what I've added to my ~/.screenrc :

# define layouts
layout new 'horizontal'
split
layout new 'vertical'
split -v
layout new  'main' 

# bind control sequences for new layouts
bind V layout select 'vertical'
bind H layout select 'horizontal'
bind ' ' layout next # <- actually means Ctrl-a + Space

With this it's possible to switch layouts with Ctrl+a Space | V | H.

(Actually, all control sequences start with Ctrl+a by default, so I'll omit it from now on.)

This solution is not ideal - after starting a screen session you initially have to tediously focus on each 'region' (parts of a layout) with TAB, and attach a process (man screen of all places insists on calling them 'windows' ) with n|p|0-9|Ctrl+c or a different method of your choice.

I imagine you'll want to detach instead of killing when possible.

... and this should hopefully cover your use case. Cheers!

Related Question