6

I'm moving from Tcsh to Bash, and I would like to take the ESC+p feature with me.

If I type , say git cl, and then press ESC+p, it should complete automatically to the last command that starts with git cl (e.g. git clone something), and place the cursor at the end.

I added the following 2 lines to ~/.inputrc:

"\ep": history-search-backward
"\en": history-search-forward

which gives me exactly what I need except that the cursor is not moved to the end.

Any ideas how to fix that?

4
+50

Try this:

"\ep": "\M-\C-p\C-e"
"\M-\C-p": history-search-backward

The first line defines a "macro" that inserts two keystrokes, \M-\C-p and \C-e. The first keystroke you define as history-search-backward, and the 2nd is already defined as end-of-line.

| improve this answer | |
  • Adding this to my inputrc right now, something I was curious about myself! – Rob Nov 1 '11 at 17:31
  • It works, but I didn't think about what it would do to searching through multiple entries. I usually will type in ssh and go through the history search. Moving the cursor to the end of the line kind of ruins that. – Rob Nov 1 '11 at 17:41
  • Exactly - I don't care for this command combination myself, because as you say it breaks searching through multiple matching entries. But it's what Misha asked for. – Andrew Schulman Nov 1 '11 at 17:44
1

Doing control-r first (or once the common part of the command typed, like after git, then typing the rest and hitting End will do it in the same number of key-presses as Esc-P :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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