I am in terminal mode on Ubuntu, and I'm running emacs with 2 buffers open, one is a ruby file, and the other is a shell (opened by typing M-x shell ), and when I switch to the shell buffer, I want to run the same command that I ran before. I would normally just hit the up arrow in a terminal window, but in emacs, it simply puts the cursor up one line.

Does anyone know of keystroke to run the previous shell command from within an emacs shell?

link|improve this question
feedback

2 Answers

up vote 5 down vote accepted

M-p does the job

link|improve this answer
Thanks! I searched a bit, but couldn't find it. – Lidmith May 11 '10 at 5:35
feedback

In addition to M-p, you can also use C-up, which I find preferable. The complementary keys M-n or C-down will get you the next command in history.

link|improve this answer
Ah, ty. That seems more natural. – Lidmith May 12 '10 at 17:56
feedback

Your Answer

 
or
required, but never shown

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