Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'd like to add a little bit of consistency between editing text on the terminal and editing text in normal OSX 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:

  • Cmd + Delete: Delete to start of line before cursor
  • Alt + Delete: Delete word before cursor
  • Alt + Left/Right: move cursor between words
  • Cmd+Left/Right: move cursor to start/end of line

Questions

  • 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 OSX 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, its disruptive. Thus, it would be nice if the terminal could support both OSX and Vim style shortcuts.

share|improve this question
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.