DEV Community

loading...

How to set Git Bash as integrated terminal in VSCode in 2021

andrewriveradev profile image Andrew Updated on ・2 min read
  "terminal.integrated.profiles.windows": {
    "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "icon": "terminal-cmd"
    },
    "GitBash": {
      "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
      "source": "Git Bash",
      "icon": "terminal-bash"
    },
    "terminal.integrated.defaultProfile.windows": "GitBash",

Enter fullscreen mode Exit fullscreen mode

As of April 2021 "terminal.integrated.shell.windows" is deprecated in VSCode.

"terminal.integrated.shell.windows": "C:\\...\\...\\bin\\bash.exe",
Enter fullscreen mode Exit fullscreen mode

To configure Git Bash as the default integrated terminal in VSCode version 1.56 on Windows 10

Step 1: Open command palette (CMD + Shift + P)
Step 2: Search "Preferences: Open User Settings (JSON)"
Step 3: Create a new field by typing "" (double quotation key). Inside the quotation type "terminal." a list of options will appear.
Step 4: Select terminal.integrated.profiles.windows. When you select terminal.integrated.profiles.windows it will be expanded to:

"terminal.integrated.profiles.windows": {
  "PowerShell": {
    "source": "PowerShell",
    "icon": "terminal-powershell"
  },
  "Command Prompt": {
    "path": [
      "${env:windir}\\Sysnative\\cmd.exe",
      "${env:windir}\\System32\\cmd.exe"
    ],
    "args": [],
    "icon": "terminal-cmd"
  },
  "GitBash": {
    "source": "Git Bash",
    "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
    "icon": "terminal-bash"
  }
},
Enter fullscreen mode Exit fullscreen mode

Step 5: Set default terminal to Git Bash

  "terminal.integrated.defaultProfile.windows": "GitBash",
Enter fullscreen mode Exit fullscreen mode

IMPORTANT
The defaultProfile.windows value must be one word to work.

  "terminal.integrated.profiles.windows": {
    "PowerShell": {
    "source": "PowerShell",
    "icon": "terminal-powershell"
  },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "icon": "terminal-cmd"
    },
    "Git Bash": {
      "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
      "source": "Git Bash",
      "icon": "terminal-bash"
    },
  }, 
  "terminal.integrated.defaultProfile.windows": "Git Bash",
Enter fullscreen mode Exit fullscreen mode

Does not work!

// End

Documentation:

Related

Discussion (9)

Collapse
rileyseaburg profile image
Riley Seaburg

Check the bracets make sure they are properly aligned.

    "terminal.integrated.profiles.windows": {
        "PowerShell": {
          "source": "PowerShell",
          "icon": "terminal-powershell"
        },
        "Command Prompt": {
          "path": [
            "${env:windir}\\Sysnative\\cmd.exe",
            "${env:windir}\\System32\\cmd.exe"
          ],
          "args": [],
          "icon": "terminal-cmd"
        },
        "GitBash": {
          "source": "Git Bash",
          "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
          "icon": "terminal-bash"
        }
    },
    "terminal.integrated.defaultProfile.windows": "GitBash",
Enter fullscreen mode Exit fullscreen mode
Collapse
melvh profile image
MelVH

Hi,
In case you have not been able to resolve your default shell in vs code, i updated mine today using the following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\Sysnative\cmd.exe",
"${env:windir}\System32\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
},
"terminal.integrated.defaultProfile.windows": "Git Bash",

This worked for me. My default shell is now Git Bash.

Further note:
Originally, there were settings in my JSHint extention configurations as follows:
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe",
"terminal.integrated.shellArgs.windows": [
"--login"
],

I removed this piece of original settings first.

Collapse
brandiqa profile image
Michael Wanyoike

One more thing, before closing the editor. Make sure to hit the Delete icon to close the Powershell tab. Otherwise when you re-open the project, it won't respect the default profile you had set but instead open Powershell again.

Collapse
kadiryumlu profile image
Kadir Yumlu

It doesnot work for me. I still have powershell as default shell.

Collapse
projektorius96 profile image
projektorius96

@kadiryumlu try this:
{
"terminal.external.windowsExec": "",
"terminal.explorerKind": "external",
"terminal.integrated.cwd": "C:\Users\%USERNAME%",
"php.validate.executablePath": "C:\xampp\php\php.exe",
"browser-preview.startUrl": "localhost/",
"phpserver.phpPath": "C:\xampp\php\php.exe",
"workbench.editor.untitled.hint": "hidden",
"workbench.colorTheme": "Visual Studio Light",
"terminal.integrated.tabs.enabled": true,
"[json]": {

    "editor.quickSuggestions": {
        "strings": true
    },
    "editor.suggest.insertMode": "replace"
},
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Command Prompt": {
        "path": [
            "${env:windir}\Sysnative\cmd.exe",
            "${env:windir}\System32\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    },
    "profile": {
        "path": "C:\Program Files\Git\bin\bash.exe",
        "args": [
            "--login"
        ]
    }
},
Enter fullscreen mode Exit fullscreen mode

}

Collapse
andrewriveradev profile image
Andrew Author

I updated the article should work now!

Collapse
ipapoutsidis profile image
Ilias Papoutsidis

Hey @andrew , it works fine for me.
Thanks

Collapse
brandiqa profile image
Michael Wanyoike

The new VS Code update has a bad UI design in the terminal. There's a second drop down after the + symbol where one can switch the terminal type and select the default type

Collapse
andrewriveradev profile image
Andrew Author

I updated the article. Now you Git Bash is the default terminal to load when you open the terminal!

Forem Open with the Forem app