A wiser person than me once said you have to listen to what people want, and give it to them. Ordinarily I’m enough of a curmudgeon to ignore that, but in this case, it’s probably true. I attracted a little attention with that commercial for screen and the vertical split patch, and a few people asked for more detail. And I’m willing to oblige.
Two caveats. First and foremost, I am not a screen expert. screen is one of those programs I hold in high esteem because it is exceptionally customizable, especially at very low levels, and I haven’t used it enough to tackle all the intricacies and finer details. screen is great stuff though, particularly if you enjoy (?!) living life at the terminal line. Which I do, these days. 😈
Second: You will want proper framebuffer support for your system. I only mention that because I happen to use a distro that requires you to include framebuffer support, and if you don’t do it right, you’ll end up with gigantamo letters and an 80×60 screen, and won’t be happy with me. It’s also worth mentioning because in a day and age when nonstandard screen dimensions are … standard, nobody wants a 1024×768 screen smeared to fit 1280×800. In that case, I strongly recommend checking out Ali Gunduz’s note about pursuing unusual framebuffer dimensions.
All right, enough with the preliminaries. The first thing we want to do is patch screen to include the vertical split. Patching is terrifyingly easy stuff, but I’m going to do it the roundabout way, just to prove my point.
The rumors are true, Ubuntu 9.04 has the split patch in place already, it’s just that the commands are a little different from the “pure” patch. Ubuntunuts use the pipe symbol to split a screen vertically, while the vanilla version uses a capital V. Which command you use is immaterial really, since screen allows you to customize your keybindings without ever leaving the comfort of your home. Isn’t life wonderful?
Arch users have the luxury of the screen-vs PKGBUILD at their command, and so can build a version of their own design, with minimal effort. I would never dream of suggesting to a Crux user how to patch a file; Crux users inhale code as a morning ritual, and will only scoff at my pitiful efforts to enlighten them on how to patch things.
All the same I enjoy messing with stuff, so I’ll patch it in Ubuntu. First, let’s go crazy.
Now we can handle some of the more complicated issues without working around sudo all the time. Yes, I know, I just committed a cardinal sin in Ubuntu … sue me. If it’s that big a deal for you, don’t do it. But all the cool kids are doing it. And if you did it, you’d be really cool too. …
Next, once you’ve succumbed to peer pressure, rip out the screen that is installed. screen and screen-profiles are part of ubuntu-desktop (which is to say, a default installation). At a terminal (and if you fear the terminal, the irony is beyond me). …
aptitude remove --purge -y screen
Next let’s get screen’s source in place, along with its dependencies. apt-get is your friend here.
apt-get build-dep screen -y
If you haven’t installed it already, build-essential (which is to say, the compilation tools) will be dragged in too. Now a small dependency that may or may not give you issues later. …
apt-get install libncurses5-dev -y
I also use checkinstall, when I visit Ubuntu.
apt-get install checkinstall -y
Let’s add the source for screen. I prefer the pure, unadulterated version.
That’s just one mirror; there are lots of places you can download it from. Now decompress it.
tar zxvf screen-4.0.3.tar.gz
You should have a folder called screen-4.0.3 there now. Change into it. Now we go from crazy to barbaric: Download the patch.
Yes, I know it says 4.0.2. It works for both versions. Now bunzip it.
Now comes the incredibly difficult, exceptionally nerve-wracking part.
patch -Np1 < wrp_vertical_split_0.3_4.0.2.diff
Tough, wasn’t it? Now let’s configure.
Customize that if you like. Check
./configure --help | less for some ideas. Now make.
And we’re one step shy of being done.
Say what you like about checkinstall; I have no opinion of it one way or another, except that it makes a nice package that I can pusharound for a few months. Now let’s check our work.
And you should get the introductory message from screen. Press a key to get beyond it. Communicate directly with screen by pressing CTRL+A, then press the question mark (?). You should see a happy help screen. With any luck, on the right is the capital V, with the vertical split command. Finished.
Okay, so now it’s in place, and we corrupted an otherwise pristine installation of ubuntu-desktop by ripping out screen and replacing it with an aftermarket part. There goes our warranty. Now let’s get it set up in such a fashion that it’s worth bragging about at work.
And this is the part where you can go really wild. Like I mentioned, one of the beautiful things about screen is that you can modify it to your heart’s delight, and no one will complain. Here’s a way to start.
hardstatus alwayslastline "%-w[%n %t]%+w%=%C %a" shelltitle '' startup_message off vbell off blankerprg cmatrix -ab -u2 idle 300 blanker screen -t centerim 0 centerim screen -t alpine 1 alpine screen -t vimwiki 9 vim
Paste that into a file called .screenrc in your home directory, and restart screen. What’s it do? Well, from here and there on the Internets, I collected a few settings I like, personally. The hardstatus line sets the bottommost line of the screen as a kind of panel, with the active application selected, and a clock in the bottom right corner. The number of options you have at your disposal there is mind-boggling, check screen’s man pages for more codes.
The shelltitle variable allows you to preset the name of new screen sessions to … whatever, and I usually prefer just a blank. Otherwise, the hardstatus line will show “bash”, if I remember right.
startup_message controls whether or not the startup message is displayed. As you might have guessed. 🙄
vbell is the visual bell, which I turn off, mostly because the entire screen flashes in reverse, which is rather like being hit squarely in the center of your forehead with a ball-peen hammer. I don’t recommend that.
blankerprg and the idle command I mentioned here; I strongly recommend cmatrix in that role, or perhaps cacafire, if you’re so inclined. Be aware that libcaca in some distros requires some of X’s baggage, which I only mention if you’re a purist like me, and you’re running free of anything from Xorg, et al.
The remaining commands spawn processes and add titles to the windows, as they are begun. The last one in the list will be the window you see when screen is done starting, so if you like to start a music player or check your e-mail first of all, put it last.
Aside from what you see there, you can dig up about a bijillion other settings and commands, all of which will customize screen to the nth degree. Experiment, and report back. I love new ideas.
So what’s left? Well, the fun part really. You’re probably wondering how screen behaves and how to get a third of the screen partitioned off, like I did in the photo. It’s easy really, if you can think about the layout at all.
Every time you split a window, screen evenly divides the space to accommodate. But if you subtract a window, depending on its place in the stack, the released area is reallocated one way or another, but not evenly. That means you can work in thirds or quarters of your screen at one time, simply by adding (with CTRL+A CTRL+S or CTRL+A CTRL+V), then subtracting (with CTRL+A CTRL+X) the appropriate portion. Remember that you can bounce between “windows” with CTRL+A TAB; the cursor shows which “window” you’re in.
It might take a little practice to predict how screen will arrange things. But, if you split the screen first horizontally, then split the bottom one vertically in half, then bounce back to the top and split it vertically three times, then X-out one of the leftmost “windows,” you can run mplayer (thank goodness for the -really-quiet option 😯 ) and come up with something like this.
It also means applications that work well in single lines or restricted spaces have an excellent role in the grand scheme of things. You can arrange one slender bit of a window at the top or bottom, run a network monitor there alongside a system profile or a chat box, or e-mail client or … oh good grief. You figure it out. (I dig images and pictures of wacky arrangements, by the way. If you get one you’re proud of, by all means share.)
Anyway, that’s about all I have at the moment. This little essay is skeletal at best, considering the potential screen has, and the fun of the vertical and horizontal splits. More information is out there; tell us what you find. 😀