Friday, December 16, 2011

Screen

It's almost finals week, and that means I'm finally done with assignments and only have to study for finals. Before really diving into studying (my first final is on Monday), I decided to take a break and relax.

One of my current pet projects is about terminal emulators. In just about every terminal emulator I've tried (such as gnome-terminal, terminator, and many others) text does not get auto reformatted. That is, when I resize the window the text does not get reformatted to fit the new window size. Mac OS X terminals actually do auto reformat text nicely, as well as the GUI-est terminal I've ever seen. I wish I could get my hands on Mac's terminal's source, but it looks like it's closed source. The other editor is too GUI for me, although I might fish through it's source some day.

I discovered that screen partially does what I want. The output of programs like cat, less, and tail all get correctly auto reformatted. However, ls does not get auto reformatted. I haven't tested it much beyond that yet.

As an experiment, I decided to make have gnome-terminal run screen by default when I run it and do all of my work inside of screen. So far I've noticed almost no differences, other than the auto reformatting I described. The main difference is screen eats my normal ctrl-a for it's own commands. Ctrl-a a does work as a normal ctrl-a. I'm considering seeing if I can change the main screen key to something other than a, although I need to find a safe character first. Maybe I'll try to change it to Mod4-a instead.

In the meantime, I've learned a little more about screen. I learned about .screenrc, which as it sounds gets run when screen is started. Right now, this is my .screenrc:

startup_message off
vbell off

Pretty simple, it suppresses the startup message that screen normally displays and switches off the visual bell. The visual bell is similar to the system beep, except instead of making a noise it flashes the entire terminal for a second. Useful, but I prefer the beep.

For anyone interested in screen who hasn't used it much, one of the most important things about screen is how to use screen commands. Ctrl-a by default is the prefix to most or all screen commands (I'm not sure if there are others). Ctrl-a ? will give you the help menu.

No comments:

Post a Comment