Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command history in emacs shell mode

Tags:

bash

emacs

In the bash shell, I can use the up arrow key to navigate to a previously entered command. But this does not work in emacs shell mode. Is there any way to enable this?

like image 752
Kris Avatar asked Apr 07 '12 14:04

Kris


People also ask

How do I see all bash history?

The command is simply called history, but can also be accessed by looking at your . bash_history in your home folder. By default, the history command will show you the last five hundred commands you have entered.

What is history command in bash?

history command is used to view the previously executed command. This feature was not available in the Bourne shell. Bash and Korn support this feature in which every command executed is treated as the event and is associated with an event number using which they can be recalled and changed if required.

What is mode in shell?

Shell mode is a derivative of Comint mode, a general-purpose mode for communicating with interactive subprocesses. Most of the features of Shell mode actually come from Comint mode, as you can see from the command names listed above.


2 Answers

M-p (and M-n for the other direction) will do the trick.

Here is the link to the Emacs manual on the subject.

like image 88
Nicolas Dudebout Avatar answered Oct 22 '22 01:10

Nicolas Dudebout


Add this to your ~/.emacs:

(define-key comint-mode-map (kbd "<up>") 'comint-previous-input)
(define-key comint-mode-map (kbd "<down>") 'comint-next-input)
like image 41
thiagowfx Avatar answered Oct 22 '22 00:10

thiagowfx