How to make ctrl+p behave exactly like up arrow in zsh

shellzsh

First of all, I am using zsh and oh-my-zsh with nearly no other customization.

In zsh, when I press up-arrow, it brings me the latest commands. And if I typed some characters before I press up-arrow, it will bring me the latest command starting with those characters. It is quite an useful feature since I issue a lot of git/vim/scp commands alternatively.

But now I am switching to a keyboard without arrow keys, and I tend to use ctrl+p instead of up-arrow for history completion. However, no matter how many characters I typed before press ctrl+p, it will always bring me the latest command (not the latest starting with those characters)

How should I configure the zsh (or oh-my-zsh) to fix this?

Best Answer

bindkey "^P" up-line-or-search
Related Question