visual-studio-codeterminalgit-bash

GitBash not showing up as a terminal option in Visual Studio Code


I am trying to insert GitBash as an option in Visual Studio Code. My settings look like so:

"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": "GitBash",
      "path": ["F:\\Code\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "GitBash"

However, at the last line, the error that Visual Studio Code gave is:

Value is not accepted. Valid values: "PowerShell", "Command Prompt".(1)
The default profile used on Windows. This setting will currently be ignored if either #terminal.integrated.shell.windows# or #terminal.integrated.shellArgs.windows# are set.

I do not understand where I went wrong.

Note: "terminal.integrated.shell.windows" is deprecated as of April 2021.


Solution

  • I believe Visual Studio Code uses your PATH variables to find which profiles are available on your machine. I am guessing you do not have the location of Git Bash set in your PATH. But, that should be fine since you specify the path property in the setting. The issue is you are also setting the source property. According to the description for the terminal.integrated.profiles.windows setting, you can either set the source or the path, not both:

    The Windows profiles to present when creating a new terminal via the terminal dropdown. Set to null to exclude them, use the source property to use the default detected configuration. Or, set the path and optional args

    Delete the source property, and see if the issue resolves and you can open a git bash terminal in Visual Studio Code.

    Also, you may need to restart Visual Studio Code after making these changes. It might be a separate bug, but the terminal.integrated.profiles.windows setting won't detect any new profiles added until you restart.