Wednesday, July 23, 2008

Where art thou iTerm?

UPDATE(2009-05-16): I found a fix for the broken meta-key problem on the iTerm bug tracker. Check out: http://sourceforge.net/tracker/index.php?func=detail&aid=1294192&group_id=67789&atid=518973

UPDATE(2008-09-26): iTerm released an update on Sept 24th. It seems to fix the mouse selection problem mentioned below but I still can't get the alt key to act as a Meta key in either local or remote connections. Key combos using alt just print out non-ASCII characters.

Leopard has a pretty decent terminal emulator in Terminal.app and I use it all the time. But before Leopard, Terminal.app left much to be desired and so I used a third party freebie called iTerm. The biggest advantage over Terminal.app was that you could open a bunch of terms in tabs instead of needing a separate window for each. Now Terminal.app has tabs and that seems to have killed interest in iTerm. As of this writing, the "News" section on the iTerm webpage hasn't had any postings in a year and a half.

I find this a little sad. iTerm still has some things going for it that haven't found their way into Terminal.app (and may never). I miss Full screen mode. I miss iTerm's ability to override the color values for ANSI colors. The default blue color (used for directories) is essentially unreadable on a black background so with iTerm I lightened up the blue. I can't do this in Terminal.app so I'm back to squinting at directory names. I also think iTerms handling of bookmarks and tabs was more intelligent than Terminal but that's almost a quibbling issue.

So why don't I still use iTerm? Three reasons. First, iTerm has weird mouse selection behavior. When you select a line of text with the mouse moving from left to right, you have to be sure to position the cursor all the way to the left of the first character you want to select. I used to end up missing the first character all the time until I managed to override my habits. Right to left selection works fine. Second, I could never get the meta/alt/option key to work correctly in remote terms. I use Meta-d and Meta-backspace in bash quite often and I could never get it to work on remote connections to my Linux machines. It's easy to get working on Terminal.app. Lastly, iTerm has never supported .term files. These are a little known secret of Terminal.app that have been around since at least 10.3 (though they may go all the way back to 10.0). They allowed me to create files that would initiate ssh connections to particular machines. I used to keep a directory in my dock with a bunch of .term files in it so that I could right-click and jump to any machine that I needed to work on. Then I started using Quicksilver and dispensed with the Dock folder altogether. I could open a new Terminal.app window with an ssh connection to my workstation just as quickly as I could type Cmd-Space ws [enter].

So iTerms's source is freely available on sourceforge. Maybe when I get several months of free time I can hack in those features. Go open source. When you find yourself frustrated with a product, all it takes is a degree in Computer Science, years of professional experience, and several months to get up to speed on a codebase.

Wednesday, July 16, 2008

ANSI Color Codes in C++

I finally got around to figuring out how to get C++ to output text in different colors (assuming your output system (terminal) supports it). It's not at all difficult , it just requires knowing the string representations of the ANSI color codes. I haven't tried it with C/printf but I can't see why it wouldn't work the same way.