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?

2 Answers 2

7
+50

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.

0
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.