Using MSYS2 with Visual Studio Code is extremely easy now thanks to the Shell Launcher extension by Tyriar.
First, install the extension and reload Visual Studio Code.
Then, open the settings.json
to edit your settings.
Add the field shellLauncher.shells.windows
. I recommend using autocompletion here so that all the default shells are added.
You should having something like this now:
{
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\System32\\cmd.exe",
"label": "cmd"
},
{
"shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"label": "PowerShell"
},
{
"shell": "C:\\Program Files\\Git\\bin\\bash.exe",
"label": "Git bash"
},
{
"shell": "C:\\Windows\\System32\\bash.exe",
"label": "WSL Bash"
}
]
}
Now you have to add the MSYS2 bash to the list of shells.
Add this shell into the list. The path to your installing of MSYS2 may be different. Just find the path to bash.exe
in /usr/bin/
.
{
"shell": "C:\\msys64\\usr\\bin\\bash.exe",
"label": "MSYS2",
"args": ["--login", "-i"],
"env": {
"MSYSTEM": "MINGW64",
"CHERE_INVOKING": "1",
"MSYS2_PATH_TYPE": "inherit"
}
}
You can choose to remove MSYS2_PATH_TYPE
if you don't want your shell to inherit all the existing PATH settings from Windows.
currently it served me changing "shell" by "path" and giving it a name, I also installed fish and I prefer to use that, I share what I achieved because I take all afternoon hehehe
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\Sysnative\cmd.exe",
"${env:windir}\System32\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Bash": {
"path": ["C:\laragon\bin\git\bin\bash.exe"]
},
"MSYS2": {
"path": "C:\msys64\usr\bin\bash.exe",
"label": "MSYS2",
"args": ["--login", "-i"],
"env": {
"MSYSTEM": "MINGW64",
"CHERE_INVOKING": "1",
"MSYS2_PATH_TYPE": "inherit"
}
},
"FISH": {
"path": "C:\msys64\usr\bin\fish.exe",
"label": "MSYS2",
"args": ["--login", "-i"],
"env": {
"MSYSTEM": "MINGW64",
"CHERE_INVOKING": "1",
"MSYS2_PATH_TYPE": "inherit"
}
},