将 Emacs M-x shell 更改为使用 Windows 10 bash

Change Emacs M-x shell to use Windows 10 bash

我使用 Windows 图形化 Emacs 有一段时间了,我正在尝试将它与 Windows 10 的新 Windows Bash 一起使用。我想要做的是,当我输入 Windows Emacs,M-x shell,我希望它使用 Windows Bash shell,而不是正常的Windows 命令。我尝试将其添加到我的 .emacs 文件中:

(setq explicit-shell-file-name "C:/path/to/bash.exe")
(setq shell-file-name "bash")
(setq explicit-bash.exe-args '("--noediting" "--login" "-i"))
(setenv "SHELL" shell-file-name)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

我从 here 得到的。这个,当我运行M-x shell报了Spawning child process: invalid argument错误。我试着省略第三行,因为它是关于争论的,但那没有任何作用。有没有办法做到这一点?提前致谢。

所以这个 defun 对我有用,可以启动 WSL bash shell.

(defun run-win-ubuntu () (interactive) (let ((shell-file-name "C:\Windows\System32\bash.exe" )) (shell "*ubuntu*")) )