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


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:


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.

  • Do you have any tips for fixing the C-up/down on Mac?
    – Kyrremann
    Sep 12, 2022 at 7:44

Your Answer

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

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