Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
ls
pwd

and that I have the following keyboard binding enabled:

bindkey '^P' history-search-backward

I have noticed that if I then type:

less documents
^P

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

1 Answer 1

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

 
discard

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.