I am running GNU Emacs on Windows so entering:
M-x 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-nameis the variable that controls which shell Emacs uses when it wants to run a shell command.explicit-shell-file-nameis the variable that controls which shellM-x shellstarts up.Ken’s answer changes both of those, which you may or may not want.
You can also have a function that starts a different shell by temporarily changing
explicit-shell-file-name:You will probably also want to pass the
--loginargument to bash, because you’re starting a new Cygwin session. You can do that by settingexplicit-bash-args. (Note thatM-x shellusesexplicit-PROGRAM-args, where PROGRAM is the filename part of the shell’s pathname. This is why you should not include the.exewhen setting the shell.