This question already has an answer here:
When I use OMZ, I have a very, very nice feature I like to call context-sensitive history. It's easier to show than describe. If I run:
% abc % cba
And then I type
% a[up], without CS history I get
% cba. With it I get
% abc. What in OMZ causes this?
EDIT: I want this to give me results based on the beginning of the command. With the substring search suggested by @Thomas Dickey, it matches if what I typed was anywhere in the command.
EDIT 2: @jasonwryan's answer in How can I search history with what is already entered at the prompt in zsh? is almost it; the only thing is that the cursor should be at the end of the new line rather than staying at its current location.