[EDITED to add:] It turns out that the actual problem here was a brainless typo I had made. The answer to my actual question is "yes, you just do the obvious thing and it works, if you aren't a moron". I'm accepting the answer that basically says that, but maybe in fact the question should be deleted.

My employer's standard setup for software development on Windows involves using MSYS. (Either traditional MSYS or MSYS2.) Is there a way to run the shell for either of these inside the new Windows Terminal?

Traditional MSYS has a Windows batch script that arranges to execute sh.exe inside whatever terminal it's being run from. You might therefore think that making a new profile in WT's profiles.json, with "commandline": "path\to\sh.exe", would do the trick. Alas, no: if I do this and ask WT for a terminal of that type, I get a plain old cmd prompt instead. (Starting in C:\WINDOWS\System32.) [EDITED to add:] Duh, not-alas, yes: if I do this then it basically does work, but this gets wrong a couple of details that the accepted answer gets right.

The thing you run to get an MSYS2 prompt is a Windows executable instead of a batch script as in traditional MSYS, but it too launches its own sh.exe. Same thing happens with that.

I guess what's going on here is that the MSYS sh.exe is just expecting to interact via stdin and stdout, whereas an executable suitable for running directly from WT needs to understand the rather complicated Microsoft console APIs, or something like that.

I've also tried, with little optimism and no success (they all produce the same result as above), the following things:

"commandline": "cmd path/to/sh.exe"
"commandline": "cmd /c path/to/sh.exe"
"commandline": "cmd path/to/msys2_shell.cmd"
"commandline": "cmd /c path/to/msys2_shell.cmd"

Is there any convenient way to get an MSYS shell running inside a Windows Terminal?

  • Some confusion. Which environment do you want to run in Windows Temrinal, msys or msys2? msys is kind of old.
    – Biswapriyo
    Nov 27, 2019 at 16:13
  • I would be happy with either. As you say, traditional MSYS is pretty long in the tooth these days, but for my purposes it would be OK. Nov 27, 2019 at 16:15

2 Answers 2


Assuming MSYS2 is installed in C:\msys2 folder, the commandline entry for Windows Terminal will be C:\msys2\usr\bin\bash.exe -i -l. Hence the entry in profile.json will be:

    // Make changes here to the MSYS2 profile
    "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
    "name": "msys2",
    "commandline": "C:\\msys2\\usr\\bin\\bash.exe -i -l",
    "hidden": false

The command launches bash.exe from MSYS2 environment with --interactive and --login options. Those options are necessary to set up environment specific to MSYS2 only. For more information about how to add entry in Windows Terminal profile.json file, see this documentation from Microsoft Temrminal GitHub repository.

  • For me, this produces the exact same result as the other very similar things I tried before (using sh.exe rather than bash.exe, and without -i -l). I didn't use the exact same GUID as yours but I assume that doesn't need anything other than to be unique. Have you tried this and found that it works? Nov 27, 2019 at 18:35
  • @GarethMcCaughan I can see the prompt. What command did not work, any simple example?
    – Biswapriyo
    Nov 27, 2019 at 18:40
  • I'm not sure what you mean by "what command did not work". When I put an entry just like yours into my profiles.json and select the "MSYS" entry from the dropdown menu, it gives me not an MSYS shell session but a cmd prompt. Nov 27, 2019 at 18:44
  • ... but, hmmmmm, when I copy-and-paste yours in and make the necessary edits, I do get an MSYS shell session, so clearly I have done something amusingly wrong somewhere. Investigating further now. Nov 27, 2019 at 18:46
  • ... Ugh. So, the answer is that I am a moron. I had mistyped "commandline" as "commandLine" and so of course nothing worked. Nov 27, 2019 at 18:49

MSYS2 has their own guide to add MSYS2 to Windows Terminal. It uses msys2_shell.cmd instead of run the shell manually.

    msys2_shell.cmd [options] [login shell parameters]

    -mingw32 | -mingw64 | -ucrt64 | -clang64 | -msys[2]   Set shell type
    -defterm | -mintty | -conemu                            Set terminal type
    -here                            Use current directory as working
    -where DIRECTORY                 Use specified DIRECTORY as working
    -[use-]full-path                 Use full current PATH variable
                                     instead of trimming to minimal
    -no-start                        Do not use "start" command and
                                     return login shell resulting
                                     errorcode as this batch file
                                     resulting errorcode
    -shell SHELL                     Set login shell
    -help | --help | -? | /?         Display this help and exit

Any parameter that cannot be treated as valid option and all
following parameters are passed as login shell command parameters.

I think the manual itself is pretty self-explanatory. The important flags here are -no-start and -defterm. But here, I wants to add more flags. The one that I added is -here that recommended by the guide, and -shell, because I want to choose another shell. You can customize it as you want.

C:\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell zsh

So, the JSON profile would be

    "guid": "{05351409-756a-416f-81c1-a97a1a2cdfe2}",
    "name": "MINGW64",
    "commandline": "C:\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell zsh",
    "hidden": false

For the GUID field, you can generate your own with [guid]::NewGuid().Guid in PowerShell, or use an online service like this one. It just identifier that this profile is different with others that might have same name.

For the latest version of Windows Terminal, you don't need edit the JSON file manually, and it also generate the GUID for you. Simply click "Add a new profile" and specify the "Command line" field.


  • What is the meaning of -defterm and `
    – bzm3r
    Sep 14, 2023 at 21:23
  • 1
    @bzm3r it is like which console host you wanna use / which terminal emulator you wanna use. In Windows 10/11 we got the legacy conhost.exe and Windows Terminal. Msys2 will use Mintty as the default conhost. set it to -defterm will make Msys2 will use Windows default conhost (Windows Terminal in this case).
    – nouvist
    Sep 14, 2023 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .