Making iTerm and naim play nicely

I've started using iTerm as my terminal client on Mac OS X. Previously, I was using the Terminal.app which comes with OS X, but that has its limitations. It also doesn't look as pretty as iTerm does when I'm using naim, the console based messaging client I use to talk on IRC, GoogleTalk, and AIM.

Out of the box, iTerm works really well and there wasn't very much I customized to make it look the way I wanted. I didn't see an option in Terminal to disable bold fonts, however iTerm has that option and it makes naim look much nicer:

Of course, I can't forget to mention one of the best features of iTerm: tabs! Yes, I can have five or six terminal windows open, and they will only take up the space of one window. Detaching a tab is as simple as dragging it away from the main window. OK, back to the point of this post.

When I started using a G4 Mac several months ago, I was using Terminal to access naim. After a lot of digging around on the web, I finally discovered how to map the keys in Terminal so they work as expected to control naim (changing screens, scrolling through the buddies list, etc). I documented my discoveries on the NaimWiki. However, to my disappointment and frustration, iTerm's default key bindings did not work with naim out of the box. I figured it would be as simple as following the steps I followed for Terminal, but that wasn't the case.

There were two problems I needed to solve: Fix the backspace key and the home, end, page up, and page down keys. The backspace key was Yfixed with the help of this blog post. I simply modified the 'delete' key mapping for the iTerm Keyboard Profile I was using and changed the hex code being sent from 7f to 0x08.

I then needed to add new entries for the other keys to work properly. For each of these keys, add a new mapping, select the key, choose 'Send escape sequence' for the action and enter the appropriate sequence:

[1~ (home)
[4~ (end)
[5~ (page up)
[6~ (page down)

That's it! You should now be able to change connections (IRC, AIM, etc) by holding down fn and pressing delete. To scroll through your buddies, or through channels on IRC, simply hold fn and press home or end. To page up and down through the conversation window, use fn and page up or page down.

You can find my addition of this information to the NaimWiki here. If you have your own tips for using iTerm, please let me know!