Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from stackoverflow.com Apr 16 '13 at 15:26

This question came from our site for professional and enthusiast programmers.

up vote 9 down vote accepted
bindkey "^P" up-line-or-search
share|improve this answer
    
Thanks a lot! I'll file an issue to oh-my-zsh to add this into its default lib/keybinding.zsh. – Gordon Gao Apr 17 '13 at 17:25
1  
You may want to add bindkey "^N" down-line-or-search as well for consistency. – Emmanuel Joubaud Dec 8 '15 at 12:45
bindkey -e

This uses emacs keybindings and seems to work for me.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .