Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to add a little bit of consistency between editing text in the terminal and editing text in normal OS X programs. I use iTerm2, but I imagine any solution would involve using readline and .inputrc which probably would work in most terminals.

Specifically, I was thinking of adding:

  • Command-Delete: Delete to start of line before cursor
  • Option-Delete: Delete word before cursor
  • Option-Left/Right Arrow: Move cursor between words
  • Command-Left/Right Arrow: Move cursor to start/end of line


  • How could .inputrc be configured to support these keyboard shortcuts?
  • Would any of these shortcuts generate conflicts with existing terminal or command-line shortcuts?
  • Are there any other shortcuts that would be useful to create consistency with standard OS X text editing keys?

As a side note, I am aware that there are Vi and Emacs style shortcuts for performing these operations. In fact I use Vi-style shortcuts quite a lot on the command-line. However, sometimes when my mind hasn't shifted modes, it’s disruptive. Thus, it would be nice if the terminal could support both OS X and Vim style shortcuts.

share|improve this question
up vote 2 down vote accepted

⌘← can be assigned to \eOH and ⌘→ to \eOF. You could assign ⌥← to \eb like in Terminal, but it doesn't work in vi mode or nano.

In emacs mode you could also add this to .inputrc:

"\e[1;9D": backward-word
"\e[1;9C": forward-word
"\e[3~": kill-word

C-v shows the escape sequence for the next key combination. ^[ is ESC in caret notation. bind -p prints currently bound commands.

share|improve this answer

Preliminary answer; still hunting for other key combinations

The following post explains how to configure Alt+left/right in Iterm2. Interestingly, it requires both the configuration of .inputrc and customisation of iTerm2.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.