如何从 Emacs 中运行 Cygwin Bash Shell? [英] How can I run Cygwin Bash Shell from within Emacs?
问题描述
我在 Windows 上运行 GNU Emacs 所以输入:
I am running GNU Emacs on Windows so entering:
M-x shell
启动 Windows 命令行 DOS shell.但是,我希望能够从 Emacs 中运行 Cygwin Bash Shell(或任何其他非 Windows Shell).这怎么能轻松完成?
launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done?
推荐答案
shell-file-name
是控制 Emacs 在运行 shell 命令时使用哪个 shell 的变量.
shell-file-name
is the variable that controls which shell Emacs uses when it wants to run a shell command.
explicit-shell-file-name
是控制启动哪个 shell M-x shell
的变量.
explicit-shell-file-name
is the variable that controls which shell M-x shell
starts up.
肯的回答变化您可能需要也可能不需要.
Ken's answer changes both of those, which you may or may not want.
你也可以通过临时改变explicit-shell-file-name
来启动不同的shell:
You can also have a function that starts a different shell by temporarily changing explicit-shell-file-name
:
(defun cygwin-shell ()
"Run cygwin bash in shell mode."
(interactive)
(let ((explicit-shell-file-name "C:/cygwin/bin/bash"))
(call-interactively 'shell)))
您可能还想将 --login
参数传递给 bash,因为您正在启动一个新的 Cygwin 会话.您可以通过设置 explicit-bash-args
来做到这一点.(注意 Mx shell
使用 explicit-
PROGRAM-args
,其中 PROGRAM 是 shell 路径名的文件名部分.这就是为什么你不应该设置外壳时包括 .exe
.
You will probably also want to pass the --login
argument to bash, because you're starting a new Cygwin session. You can do that by setting explicit-bash-args
. (Note that M-x shell
uses explicit-
PROGRAM-args
, where PROGRAM is the filename part of the shell's pathname. This is why you should not include the .exe
when setting the shell.
这篇关于如何从 Emacs 中运行 Cygwin Bash Shell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!