你如何在 emacs shell 中运行前面的命令?

Lid*_*ith 47 shell emacs ubuntu

我在 Ubuntu 上处于终端模式,我正在运行 emacs 并打开 2 个缓冲区,一个是 ruby​​ 文件,另一个是 shell(通过键入 Mx shell 打开),当我切换到 shell 缓冲区时,我想要运行我之前运行的相同命令。我通常只会在终端窗口中点击向上箭头,但在 emacs 中,它只是将光标放在一行上。

有谁知道从 emacs shell 中运行上一个 shell 命令的击键?

vav*_*ava 62

M-p 做这份工作


Pra*_*h K 26

除了M-p,您还可以使用C-up,我觉得这更可取。补充键M-nC-down将为您提供历史上的下一个命令。

  • 它似乎也无法在我的 Mac 上运行; C-up 映射到 Mac 特定的功能。 (3认同)

thi*_*wfx 5

您还可以将其添加到您的 emacs init 文件中:

(define-key comint-mode-map (kbd "<up>") 'comint-previous-input)
(define-key comint-mode-map (kbd "<down>") 'comint-next-input)
Run Code Online (Sandbox Code Playgroud)