Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Say I have the following entries in my command history:

less documents/doc1.txt
less documents/doc2.txt
less files/file1.txt
less files/file2.txt

and that I have the following keyboard binding enabled:

bindkey '^P' history-search-backward

I have noticed that if I then type:

less documents

ZLE brings

less files/files2.txt

as the first option, rather than:

less documents/doc2.txt

Why is that? Is there a way to make history-search fix everything on the left of my cursor and iterate through the history with it?

share|improve this question
up vote 2 down vote accepted
bindkey '^P' history-beginning-search-backward

You might prefer up-line-or-history-beginning-search.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.