2 Posts for March 2008

Git-Style Automatic Paging in Ruby

Posted March 18, 2008

I was using Chris Wanstrath’s cheat the other day, seeing if there were any cool git features I was missing out on (did you know you can color the output?). If you haven’t come across it yet, cheat is a nice little Ruby utility that displays “cheat sheets”— user-generated pages of text that serve as miniature reference manuals.

Unfortunately, some of these cheat sheets can get pretty long. The git one is 228 lines. Some of the text went off the top of my terminal. I sighed and typed in cheat git | less, thinking once again how nice it would be if more programs followed git’s example and automatically paged their output.

Although git’s not usually held up as a paragon of usability1, there are a few places where it shines. My favorite is how it’ll run less on its output when the output is too big to fit on my terminal screen. Then I can easily scroll and search through the text.

Since I had a bit of time with nothing urgent to do, I decided to take a crack at making cheat page like git. Two and a half hours later, after digging through git’s source, getting help from the good folks in #git and #ruby-lang on Freenode, and receiving tons of bug fixes from Kevin Ballard, I got it to work.

Putting it in Perspective

Posted March 8, 2008

One of my favorite features of wmii is tags1. These allow you to divide up windows into categories based on whatever you want.

The basic idea is really simple. Each window has a set of strings associated with it, called its “tags.” At any given moment, you are “viewing” a single tag. This means that only windows with that tag are displayed.

What’s more, each tag has a certain configuration of windows. This means that I can have Firefox in the upper-left corner for my programming tag but taking up the whole screen for my web tag.