Apr 8, 2012

Mac OS X Lion and iTerm 2 Keybindings

I had to switch from Linux to Mac OS X Lion (10.7) at my work place. After getting used to Linux bash shell, I did not like the Mac terminal at all. I've install iTerm 2 and played with its keybindings and I've got the following useful keyboard shortcuts working.
  • To move cursor word-by-word  backward: Mapped Option + Left Arrow key to "Send Escape Sequence" and b
  • To move cursor word-by-word  forward: Mapped Option + Right Arrow key and "Send Escape Sequence" and f
  • To move cursor to the beginning of the sentence: Mapped Option + Up Arrow key to "Send Hex Code" and 1
  • To move cursor to the end of the sentence: Mapped Option + Down Arrow key to "Send Hex Code" and 5
  • To delete a word-byword ( backward-kill-word ): Mapped Option + BackSpace key to to "Send Hex Code" and 17
The keybindings can be changed from Preferences > Keys (or Preferences > Profiles > Keys). Since the profile level shortcuts were not useful I got rid of most of them from Preferences > Profiles > Keys.

Additionally, these built-in shortcuts will be useful:
  • Ctrl a : Goto the beginning of sentence.
  • Ctrl e : Goto the end of the sentence.
  • Ctrl w : Delete words backward.

These were couple of useful articles helped me to fix this:

3 comments:

Anonymous said...

Thanks for this tutorial, straight forward and very helpful!

Unknown said...

Worked perfectly. Very simple and useful, thank you.

Unknown said...

For deleting the whole line before the cursor, send hex code: 0x15

Source: http://stackoverflow.com/questions/15733312/iterm2-delete-line