Makes history-substring-search use term specific up and down buttons.

Fixes #2089 and problems with some linux distributions and/or terminals.