5

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

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 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.

2 Answers 2

4

⌘← 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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .