Repeat last command matching "two words" zsh

Solution 1:

!?foo bar

See http://zsh.sourceforge.net/Doc/Release/Expansion.html#Event-Designators

Edit: No, you must not escape the spaces. If you need to add something that is not part of the history expansion, separate it with another ?, e.g.:

echo hello
echo foo
!?echo hello? world # runs "echo hello world"