@johnnydecimal How I'm getting on is …rather lost!
I've added the lines you suggested for aliases and history search, but don't know how to make them do their thing. (This reminds me that the intuition I've developed for GUIs doesn't apply here—I need different skills.)