bash emacs shell 模式下的命令历史

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10055338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:58:29  来源:igfitidea点击:

Command history in emacs shell mode

bashemacs

提问by Kris

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?

在 bash shell 中,我可以使用向上箭头键导航到以前输入的命令。但这在 emacs shell 模式下不起作用。有什么方法可以启用此功能吗?

回答by Nicolas Dudebout

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

M-pM-n对于另一个方向)会起作用。

Here is the link to the Emacs manualon the subject.

这是有关该主题的 Emacs 手册链接

回答by thiagowfx

Add this to your ~/.emacs:

将此添加到您的~/.emacs

(define-key comint-mode-map (kbd "<up>") 'comint-previous-input)
(define-key comint-mode-map (kbd "<down>") 'comint-next-input)

回答by Daniel

C-pand C-nand C-rwork in (vanilla) bash too, along with some other emacs keys. Very handy.

C-p并且C-nC-r使用(vanilla)bash 以及其他一些 emacs 键。非常便利。

回答by Uday Reddy

In Gnu Emacs, the menu for the Shell mode is called "In/Out". (I think it also covers the more general mode called "comint".)

在 Gnu Emacs 中,Shell 模式的菜单称为“In/Out”。(我认为它还涵盖了称为“comint”的更通用的模式。)