Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug: history-search-backward ignores search text after first space character?



On Jul 22, 12:56pm, Sridhar Sarnobat wrote:
}
} # try to autocomplete based on the history. I want "git checkout -" to
} be filled in, but instead "git status" is filled in.
} git c<history-search-backward>
} git status
} 
} Notice the space and c that I typed in are ignored in the autocomplete.

Read the doc:

history-search-backward (ESC-P ESC-p) (unbound) (unbound)
     Search backward in the history for a line beginning with the first
     word in the buffer.

Note that only the first word is used for that widget.

} I assume this is some shortcoming of the zsh completion system. Is this
} true? Or am I misunderstanding the functionality?

History search has nothing to do with completion (though completion might
search the history), so yes, you're misunderstanding.

What you want in the example shown is history-beginning-search-backward, 
which is not bound by default.  Add

zle -A history-beginning-search-backward history-search-backward
zle -A history-beginning-search-forward history-search-forward

to your .zshrc (there are other ways to accomplish the same thing if
you still want to be able to use the original history-search-backward
and -forward widgets).



Messages sorted by: Reverse Date, Date, Thread, Author