Chris
Chris

Reputation: 7174

How can I start Git Bash via Windows Terminal with environment variables set?

I am running Windows Terminal and Git Bash on my machine. I want to integrate Git Bash into Windows Terminal, but I want to set the environment variable MSYS_NO_PATHCONV=1 when running Git Bash via Windows Terminal.

I do not want to add this to my system environment variables, because I want to be able to start Git Bash outside of Windows Terminal without this environment variable.

To add Git Bash to Windows Terminal, I have created the following entry in Windows Terminal's profiles.json file:

        {
            "guid": "{3a20b825-3d22-41ed-b575-9006741aff64}",
            "name": "Git Bash",
            "commandline": "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
            "icon": "C:/Program Files/Git/mingw64/share/git/git-for-windows.ico",
            "startingDirectory": "~",
            "hidden": false
        }

Here is what I have tried so far to get the environment variable to Git Bash:

Is there any way that I can start my Git Bash in Windows Terminal with my custom environment variable without adding it to the system's environment variables?

Upvotes: 4

Views: 11097

Answers (2)

Basix
Basix

Reputation: 67

You may want to edit msys2.ini directly in your MSYS2 installation if you want to keep that behaviour on other terminals.

Upvotes: 1

krisz
krisz

Reputation: 2696

"commandline": "cmd.exe /C \"set MSYS_NO_PATHCONV=1 && \"C:\\Program Files\\Git\\bin\\bash.exe\"\"",

Or append export MSYS_NO_PATHCONV=1 to ~/.bashrc.

Upvotes: 4

Related Questions