5

I recently added the following lines to my .inputrc:

"\e[A": history-search-backward
"\e[B": history-search-forward

However, I noticed when using this that my cursor does not jump to the end of the line. For example, if I type ls then hit up, my terminal will look like this (| being the cursors):

ls |verylongdir

What I want is:

ls verylongdir|

I believe zsh behaves this way with the same command. Is there any way to do this in bash?

  • 1
    zsh does not behave that way by default. The bash-style is represented by history-beginning-search-backward. I had to load history-search-end and define and use its history-beginning-search-backward-end widget instead. – wrlee Aug 8 '19 at 16:47
  • @wrlee This is helpful. For the zsh newbies among us, the 2 statements I required were (each on a separate line): autoload -U history-search-end; bindkey '^[[A' history-beginning-search-backward-end – Zack Burt Jun 29 at 12:42
0

I had the same question and managed to find the solution with some experimentation.

I added the following to my .inputrc

"\eOA": history-search-backward # Up
"\eOB": history-search-forward  # Down
"\C-P": "\eOA\C-E"              # Ctrl-P
"\C-N": "\eOB\C-E"              # Ctrl-N

This binds two hotkeys to Ctrl-P and Ctrl-N. One for history search, and the other Ctrl-E for end-of-line.

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