According to the msys.bat
script, the actual executable that is launched depends on your TTY settings. The default setting uses the native command prompt and launches the sh.exe
file as you can see from the following snippet:
:startsh
if NOT EXIST %WD%sh.exe goto notfound
start %WD%sh --login -i
exit
To get this to work in Visual Studio Code, you will need to add the following user settings:
"terminal.integrated.shell.windows": "C:\\MinGW\\msys\\1.0\\bin\\sh.exe",
"terminal.integrated.shellArgs.windows": ["--login", "-i"]
The path to the sh.exe
file may be different depending on your install location for MSYS.
EDIT: (2019-01-20)
While the above still works for MSYS v1.0, I have since switched over to MSYS2 (https://www.msys2.org/). You can use the following settings to setup your Visual Studio Code to work with MSYS2 just as for v1.0 (once again, your install location might be different than mine):
"terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": ["--login", "-i"]
For extra-credit, we are going to modify an environment variable so that we always open the terminal in the current directory. There are various ways to accomplish this via scripting etc. However, the simplest way to do it, in my opinion, is to use the CHERE_INVOKING
environment variable. By setting this flag to 1
it will inform the shell to use the current directory as the default entry point. Here is a complete tutorial on how to enable this flag:
- Press the windows key and type
run
and hit enter
In the run dialog, type the following:
rundll32.exe sysdm.cpl,EditEnvironmentVariables
In the Environment Variables dialog that is opened, add a new user variable called CHERE_INVOKING
and set it's value to 1
.
With this flag enabled in the Windows system, it should automatically open the terminal from the location where you called the bash.exe
executable. For Visual Studio Code, this will be your root project directory. Enjoy!