DEV Community


Posted on

Make the integrated shell of Visual Studio Code to bash of MSYS2


This article is a translation of the post written in Japanese below:

Visual Studio Code 15.1の統合シェルをMSYS2のbashにする - Qiita

Target Visual Studio Code version

15.1 or later

Previous research

First of all, when you google about this story, the story that uses git of msys2 gets mixed, there is no googleability.

Well, first of all, you can find this post:

Visual Studio CodeのIntegrated Terminalでmsys2のzshを使う - 備忘録β版

Then, there is such information below:

(en)There seems to be an execution module by mattn, so it seems good to use it. (See comment field)
Visual Studio Code で msys2 の bash を使う方法 · GitHub

So, I watch that:

go でbash-login.goをビルドした後、出来上がったexeを以下の様に指定する。
(en)After buildin bash-login.go with go, specify the completed exe as follows.

Well... build with go ...? I feel lazy even if I need to build only once.

While watching as if there is any other information,

Visual Studio Codeの統合シェルをMSYS2のBashにしたら.bash_profileが読み込まれなかった - Qiita

Although it can be found. However, they says:

Do not open workspace as working directory

Moreover, it is ridiculous to use VSCode extension to resolve it. WTF!

The way to make the integrated shell of Visual Studio Code to bash of MSYS2

Write below in setting.json:

    "": "C:\\msys64\\usr\\bin\\bash.exe",
    "": {
        "MSYSTEM": "MINGW64",
        "CHERE_INVOKING": "1"
    "": [
    "terminal.integrated.cursorStyle": "line"
Enter fullscreen mode Exit fullscreen mode

terminal.integrated.cursorStyle is optional.


Specify full-path for bash. Be careful not to specify the bash not part of msys2(ex. the bash of git-bash).

You can set environmental variable when create process.


Every MSYS2 user will know that MSYS2 has 3 mode, MSYS, MINGW32, MINGW64, and $PATH is also(/usr/bin, /mingw32/bin, /mingw64/bin).

MSYS is almost only for creating msys2 package.

MINGW32 is based on the gcc that exception model is dwarf, not SEH, due to patent of Borland, for i686.

MINGW64 is main environmental.


For flags that decide whether to set the working directory to the path of environment variable $HOME when logging in to bash, setting it to 1 prevents movement.

In the post below:
Visual Studio Codeの統合シェルをMSYS2のBashにしたら.bash_profileが読み込まれなかった - Qiita
they says that cannot open workspace directory as current directory. The reason is they forget to set this flag. No VSCode extension is required like @catfist

Well, msys2_shell.cmd's code is too unreadable, so it's unavoidable if they did not understand.


Passing --login, -l will same effect.

Now, let's read man bash.

BASH(1)                                                      General Commands Manual                                                     BASH(1)

       bash - GNU Bourne-Again SHell
       -l        Make bash act as if it had been invoked as a login shell (see INVOCATION below).

              Equivalent to -l.

              Do  not  read  either  the  system-wide  startup  file  /etc/profile  or any of the personal initialization files ~/.bash_profile,
              ~/.bash_login, or ~/.profile.  By default, bash reads these files when it is invoked as a login shell (see INVOCATION below).
Enter fullscreen mode Exit fullscreen mode

see INVOCATION below

Please read it yourself.

To summarize, if you do not pass -l or --login, ~/.Bash_profile will not be loaded.

More detail, That is about login shell and interactive shell. Please see below:



Specify the style of cursor of terminal. The default is "block". I like line-style so that specify "line".



Top comments (1)

airbus5717 profile image

thanks alot for this