Making iTerm more native

15 Oct 2013

OSX has some system-wide text editing shortcuts that are being widely used, such as Alt + ←, Alt + →, Alt + delete, CMD + delete. The caveat is that they don't work in your terminal out of the box. Terminal wants you to use Emacs-style keybindings.

In this short post, you'll see how to add all of the mentioned commands to iTerm. Hint: this will work in terminal Vim as well, but I didn't tell you that.

Preferences

You can access them by pressing CMD + , (also works in any other app). Navigate to the Keys tab - this will be the place where we'll enable our keybindings. For adding each command, you'll need to click on the + sign below the 'Global Shortcut Keys'.

Alt + ← / Alt + →

It's commonly used to jump between words. It works in any native OSX app, including iPhone simulator.

  • Press +
  • Enter the keyboard shortcut
  • Select Send Escape Sequence

For Alt + ←, enter B in the text field. For Alt + →, enter F in the text field.

Command + ← / Command + →

Emacs keybinding: Ctrl + A / Ctrl + E

It's commonly used to jump to beginning / end of the line respectively. It works in any native OSX app, including iPhone simulator.

  • Press +
  • Enter the keyboard shortcut
  • Select Send Hex Code

For Command + ←, enter 0x1 in the text field. For Command + →, enter 0x5 in the text field.

Alt + delete

Emacs keybinding: Ctrl + W

It's used for deleting to beginning of the current word.

  • Press +
  • Enter the keyboard shortcut (Alt + delete)
  • Select Send Hex Code
  • Enter 0x017

Command + delete

Emacs keybinding: Ctrl + U

It's used for deleting to beginning of the current line. This is one of my favorite text-editing keybindings in OSX.

  • Press +
  • Enter the keyboard shortcut (Command + delete)
  • Select Send Hex Code
  • Enter 0x015



That's pretty much it. Enjoy your new super duper iTerm!