9

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:

ls
./script
./script
./script
make

and press M-p three times, I want it to go to ls command.

Or, alternatively, how can I define a command like this?

Anton
  • 163
  • 9

2 Answers2

7

The shell you get from M-x shell is based on comint, so you can set comint-input-ignoredups to t in order to get the behaviour you want. The help even mentions bash:

comint-input-ignoredups is a variable defined in `comint.el'.

Documentation:

If non-nil, don't add input matching the last on the input ring.

This mirrors the optional behavior of bash.

This variable is buffer-local.

You can customize this variable.

Omar
  • 4,732
  • 1
  • 17
  • 32
1

You can also use M-x comint-dynamic-list-input-ring and invoked by C-c C-l. You can also set C-h v comint-input-ignoredups to t to see unique commands only in above list.

Omar
  • 4,732
  • 1
  • 17
  • 32
aartist
  • 133
  • 5