13

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?

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

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

14
bindkey "^P" up-line-or-search
  • 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
  • 2
    You may want to add bindkey "^N" down-line-or-search as well for consistency. – Emmanuel Joubaud Dec 8 '15 at 12:45
4
bindkey -e

This uses emacs keybindings and seems to work for me.

  • In your shell rc file ~/.zshrc if you set export EDITOR=vim then also key binding in shell will change to vim. In this case manually set key binding to emacs mode by bindkey -e – MutantMahesh May 3 '17 at 5:44

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.