Now, I when I invoke the command using the exclamation mark, it works with the line number, but if I type the first few letters for some reason it runs something slightly different:
Not a direct answer, but I use history with the help of these definitions in ~/.bashrc:
bind '"\e[A":history-search-backward' # up arrow
bind '"\e[B":history-search-forward' # down arrow
With them I can find older commands easily:
just using up and down arrow keys
by writing the start of a command and pressing up and down arrows I will get the command I want, even when there are many commands in history starting the same
This way I never have to use ! and a number (which for me seems quite clumsy).
Can confirm these are awesome. I’ve added them as well, so now I no longer need to suffer (typing “gnome-ext” and pressing up arrow looks up the correct command).
So thank you for this. While not an answer, it is indeed even better than an answer.
Still curious though to find out why bash is behaving like this with the exclamation mark…