2

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?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Amelio Vazquez-Reina
  • 40,169
  • 77
  • 197
  • 294

1 Answers1

2
bindkey '^P' history-beginning-search-backward

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

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175