Jonathan Tran on 20 Dec 2009 12:57:16 -0800 |
A while back, Philip showed us how to move the control modifier in Emacs to the command key on Mac [1] to allow us to comfortably use our thumbs on the command key, instead of our pinkies, w/o disturbing all the command-shortcuts of other Mac apps. I started developing more on my Mac recently, so I ended up spending a while figuring out how to do the same thing for iTerm. Thought others might be interested... I found this to be essential on my MacBook due to its tiny Control key in the worst possible spot. Go to Bookmarks, Manage Profiles. In your keyboard profile (probably Global), add a new mapping for each key that you care about. Since I was making all the Control-<blah> keys work by pressing Command- <blah>, I added mappings like this. Note: the (!) means you need to check the High Interception Priority checkbox to override the normal Command-shortcuts. Key Combination | Action cmd-hex code 0x61 | send hex code 1 (!) cmd-hex code 0x62 | send hex code 2 (!) cmd-hex code 0x63 | send hex code 3 (!) cmd-hex code 0x64 | send hex code 4 (!) ... and so on, all the way up to 0x7a. (I decided to omit some so that Command-T still makes a new tab, for example.) The first number corresponds to the hex ascii code of the key you are typing. The second number is what to do when someone presses that key. Through trial and error (I couldn't find documentation on any of this...) I discovered that sending hex code n is equivalent to Control-<n + 0x60>. The only thing I really miss that this doesn't handle, is undo (Control-/). Since the hex code of / (0x2f) is less than 0x60, the above trick of subtracting 0x60 doesn't work. (Same thing w/ Control- _.) So as a workaround, I ended up creating a new key binding to undo that could easily be mapped to in iTerm. In my .bashrc, I added this line, which binds Control-{ (a key combination I don't use on the command-line) to undo: bind "\C-{":undo Then in iTerm I added a mapping like this: cmd-/ | send hex code 1B (!) ...Note: you have to enter it as hex code 0x2f. It then shows up as "cmd-/". Be careful, though, b/c an apparent bug in iTerm converts it to "cmd-num-/" if you modify it. [1] http://groups.google.com/group/philly-lambda/browse_thread/thread/f95ffffeb875d8fd/
|
|