How do I integrate MSYS2 shell into Visual studio code on Window?

前端 未结 9 786
慢半拍i
慢半拍i 2020-12-13 02:55

I tried to integrate MSYS2 shell into Visual studio Code integrated terminal. Here\'s my user settings:

{
    \"terminal.integrated.shell.windows\": \"C:\\\\         


        
9条回答
  •  自闭症患者
    2020-12-13 03:29

    To inhibit the working directory change from your current directory, set the CHERE_INVOKING environment variable to a non-empty value:

        "terminal.integrated.env.windows": {
            "CHERE_INVOKING": "1"
        },
    

    In MSYS login scripts, setting the CHERE_INVOKING variable serves only to prevent a shell from doing a cd "${HOME}", and nothing else.

    If you require a MinGW toolchain, set the MSYSTEM environment variable to select a toolchain. Recognized values are MSYS (default), MINGW32 or MINGW64.

        "terminal.integrated.env.windows": {
            "MSYSTEM": "MINGW64",
        },
    

    In full, the VS Code settings might look like so:

    {
        "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
        "terminal.integrated.shellArgs.windows": [
            "--login",
        ],
        "terminal.integrated.env.windows": {
            "CHERE_INVOKING": "1",
            "MSYSTEM": "MINGW64",
        },
    }
    

    To provide some context on the very cryptic nomenclature of CHERE_INVOKING: chere is apparently a Cygwin command for installing and managing a "Command Prompt Here" folder context menu item. Although MSYS2 inherits the environment variable from Cygwin, it doesn't actually inherit the command itself.

提交回复
热议问题