Search code examples
visual-studio-codemingw-w64msys2

How to run MSyS2 Mingw64 bash in VsCode terminal along with cmd prompt?


I have my settings set as :

"terminal.integrated.shell.windows":"C:\\msys64\\usr\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": ["-i"],
    "terminal.integrated.env.windows": {
        "PATH": "/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/"
    },

this works fine, but to change my terminal to Cmd Prompt I have to manually change my setting to : "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"

I tried using the shell launcher extension to make switching between terminals easier, but that doesn't work for mingw bash. I use the extension for running Octave gui which works fine. I guess it is because no Path is specified for the shell when launching through this extension. Is there anything else I can do?

"shellLauncher.shells.windows": [
        {
            "shell": "C:\\Windows\\System32\\cmd.exe",
            "label": "Cmd Prompt"
        },
        {
            "shell": "C:\\Windows\\<sysnative>\\WindowsPowerShell\\v1.0\\powershell.exe",
            "label": "PowerShell"
        },
        {
            "shell": "C:\\msys64\\usr\\bin\\bash.exe",
            "label": "mingw bash"
        },
        {
            "shell": "C:\\Octave\\Octave-5.2.0\\mingw64\\bin\\octave-gui.exe",
            "label": "Octave gui"
        }
    ],

Solution

  • {
                "shell": "C:\\msys64\\usr\\bin\\bash.exe",
                "label": "mingw bash",
                "env" : {"PATH": "/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/"
                }
            }