Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Emacs M-x shell to use Windows 10 bash

I have been using the Windows graphical Emacs for a while, and I am trying to use it along with Windows 10's new-ish Windows Bash. What I want to do is, when I type into Windows Emacs, M-x shell, I want it to use the Windows Bash shell, instead of the normal Windows cmd. I tried adding this to my .emacs file:

(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)

I got it from here. This, when I ran M-x shell gave a Spawning child process: invalid argument error. I tried omitting the third line, since it was about arguments, but that did nothing. Is there a way to do this? Thanks in advance.

like image 631
kungfushark Avatar asked Dec 13 '25 02:12

kungfushark


1 Answers

So this defun works for me to start up the WSL bash shell.

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

like image 115
Jerry Asher Avatar answered Dec 15 '25 19:12

Jerry Asher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!