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.
Best Answer
⌘← 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:
C-v
shows the escape sequence for the next key combination.^[
is ESC in caret notation.bind -p
prints currently bound commands.