Just found out, adapting from
this answer on unix-stackexchange.
I had to adapt it somewhat because I already had "history -a" running all the time, so it would display it by default, which I don't like. Instead, the current directory would be better. So, the relevant bits of my ~/.bashrc are probably these, I think:
Code:
shopt -s histappend histreedit histverify cdspell dirspell no_empty_cmd_completion cmdhist checkwinsize autocd
...