1

In a shell in a terminal (Gnome Terminal + bash), the up and down keys allow me to browse through my command history.

In shell-mode inside emacs, the up and down keys move around the buffer, which is bit strange (but I admit can be useful in order to copy-paste parts of the buffer).

How can I browse the command history in shell-mode?

2

M-p and M-n let you navigate through the shell history. You can try C-up and C-down too.

There are other ways, as explained in Shell History on the manual.

0

Note C-up and C-down will not work on Mac OSX. And for those of you who use OSX at home and Linux (e.g. Debian, Ubuntu, CentOS) at work, you will want some degree of consistency in your Emacs. Consequently, M-p is the better choice. Note M-p will take you up to the previous command in history in the Emacs shell. But what if you want to search for a command in history? You would use:

M-r

You will receive a prompt in the shell (not the mini buffer) that says:

Regexp history I-search backward

Begin typing and it will invoke previous commands you use. Press ENTER to select the desired command in the history buffer.

New contributor
Donato is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.