In Emacs shell, is there a command similar to M-p but which would skip repeated commands? That is, it would go to the next different command. Similar to regular Linux terminal.
So if I were to run:
and press M-p three times, I want it to go to ls command.
Or, alternatively, how can I define a command like this?