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.
Changing Default Command Line Shell Then, click on the arrow on the side of a plus (+). Here, choose Select Default Profile. Then, select any other type of command line shell. Then, restart vs code and try working on terminal.
Another way to select a default terminal is to open up a new terminal in VS Code. Next to the big plus sign, click on the dropdown and select “Select Default Profile“. From the dropdown select “Git Bash” and you're all set. Reopen a new terminal to make sure Git Bash opens up as default.
To open the terminal: Use the Ctrl+` keyboard shortcut with the backtick character. Use the View > Terminal menu command. From the Command Palette (Ctrl+Shift+P), use the View: Toggle Terminal command.
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.
Many clients will require me to work on a Windows laptop for access to their networks. Fortunately, I can change the settings within VS Code to use Git Bash as the built-in terminal.
Now dwelling further to the integration of GitBash with VSCode we need to follow sequential steps in order to integrate Git Bash with Visual Studio Code which is as follows: Add the properties to the setting page. Step 1: Open Terminal in VScode by using the shortcut key Ctrl+~.
Step 1: Open Terminal in VScode by using the shortcut key Ctrl+~. Here you will see that currently, it has PowerShell and we have to add bash to it. Step 2: Then, you have to open settings by File->Preferences->Settings or by pressing Ctrl+, . You have to click on the Open Settings (JSON) icon as shown in the image below:
VS Code version 1.57.1.
Added path of Git, Git\bin, Git\cmd in env. Had "Git Bash" profile with source and path elements. Removed source and kept only the path. When adding defaultProfile as "Git Bash" got "Value is not accepted" error. Restarting VS Code did not help.
Changing "Git Bash" to "GitBash" (space removed) finally worked for me:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": ["D:\\ProgramFiles\\Git\\bin\\bash.exe"],
"args": []
},
...
}
"terminal.integrated.defaultProfile.windows": "GitBash"
I am not sure if space is actually the problem. Because there is a profile "Command Prompt" with space in its name and recognized!!! To confirm this further, changed "PowerShell" to "Power Shell", and it worked too.
I am not clear how space matters only in the "GitBash" profile.
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 thepath
and optionalargs
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.
For anybody using a custom dir for git installation: It does not work with Version: 1.60.2 (user setup)
Win10 User:
{
"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"
},
},
"terminal.integrated.env.windows": {
},
"terminal.integrated.defaultProfile.windows": "Git Bash"
}
I have VS Code 1.63.2
Removing the source
property or the space in "Git Bash"
didn't help. But I found this on their official site and I noticed that the .exe
file itself is specified in path
:
{
"terminal.integrated.profiles.windows": {
"My PowerShell": {
"path": "pwsh.exe",
"args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
}
},
"terminal.integrated.defaultProfile.windows": "My PowerShell"
}
So I tried adding \\bash.exe
to the path in the settings and it worked:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": "D:\\Git\\bin\\bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With