I found a command a couple of months ago that made my bash history auto-complete on what\'s already on the line when pressing the up arrow:
$ vim fi
With ohmyzsh, use this in your .zshrc :
bindkey '^[OA' history-search-backward bindkey '^[OB' history-search-forward
To reload, source ~/.zshrc or relaunch terminal.
source ~/.zshrc
Source: https://superuser.com/a/418299/71680