Bash’s equivalent of Tcsh’s ESC+p

bashinputrc

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?

Best Answer

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.

Related Question