Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode error in settings when trying to set Git Bash as default profile for terminal

I tried to set Git Bash as the default terminal in VSCode, but I can't do it successfully. I've tried following the next articles:

  1. How do I use Bash on Windows from the Visual Studio Code integrated terminal?
  2. How to Add Git Bash to VsCode

But they haven't resolved my issue.

I managed to generate profiles in settings.json, but Git Bash doesn't work for some reason unknown to me and VsCode shows an error.

My settings.json:

{
    "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",
            "path": "C:\\git-sdk-64\\git-bash.exe",
            "args": [
                "--login",
                "-i"
            ]
        },
        "Cygwin": {
            "path": "C:\\cygwin64\\bin\\bash.exe",
            "args": [
                "--login"
            ]
        }
    },
    "terminal.integrated.defaultProfile.windows": "Git Bash"
}

The error:

enter image description here

Does anyone know how to fix this?

My VsCode version:

Version: 1.57.1 (user setup)
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:28:07.755Z
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19042

Edit:

I use git SDK, which is like git-bash but not exactly. Maybe this is the problem?

like image 708
a_girl Avatar asked Jul 08 '21 09:07

a_girl


People also ask

How to configure Git Bash as default Integrated Terminal in VSCode?

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."

How do I open Git Bash in Visual Studio Code?

The drop-down includes every shell that is installed in your system that VS Code was able to detect. Now simply select Git Bash and open up a new terminal window by pressing down CTRL + SHIFT + ~ (tilde) to check if Git Bash opens up as the default terminal.

How do I change the default path of a Git profile?

Type the name of the profile that need to be created and press Enter Then it will open the setting page and change the path to your terminal path After struggling with this, a simple solution i found, at least in my case where git is not installed in default path, is to make a symbolic link with this command:

How to create new Git bash profile in PowerShell?

After that, I thought bc of some reasons the Git Bash is not counted as a profile. So I tried to create a new profile by pressing ctrl+shift+p then terminal: select default profile then I pressed configure button of Powershell. And after that when I try to type Git Bash they said I already have a profile with Git Bash name.


1 Answers

this finally worked for me

"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": {
            "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
            "args": [],
            "icon": "terminal-bash"
        }
    },
    "terminal.integrated.defaultProfile.windows": "GitBash"
}
like image 129
timchew2012 Avatar answered Nov 15 '22 08:11

timchew2012