Elliot
Elliot

Reputation: 545

VSCode Integrated Terminal creates a separate window

Just installed VSCode and git bash.

I've added the following lines to the settings.json file:

{
    "terminal.integrated.shell.windows": "D:\\Program Files\\Git\\git-bash.exe" 
}

When I press Ctr+` to open the integrated shell window, instead of opening inside the main editor at the bottom it opens a new window:

Git Bash Winow

Why isn't it showing in the usual place?

Upvotes: 24

Views: 15574

Answers (8)

JDB
JDB

Reputation: 25875

According to this vscoode GitHub Issue (#7286):

... git-bash.exe is a Windows application (with WinMain as entry), but bash.exe is a console application (with main as entry). To be used as integrated shell, the executable must be a console application, so that stdin/stdout/stderr can be redirected.


CAUTION
Since the original question was posted (over 7 years ago), "Git Bash" was added as a default profile. The configuration below will replace the default profile.

As of April 2021 (v1.56), the recommended approach is to use:

"terminal.integrated.profiles.windows": {
  "Git Bash": {
    "path": "C:\\Path\\To\\Git\\bin\\bash.exe"
  },
  // ... additional profiles
}

To set Git Bash as the default profile, use the following:

"terminal.integrated.defaultProfile.windows": "Git Bash"

Upvotes: 23

Hetan Thakkar
Hetan Thakkar

Reputation: 21

If you are using Windows, you should try installing PowerShell 7. It resolves the issue.

Upvotes: 1

Vijin Paulraj
Vijin Paulraj

Reputation: 4648

I had the same problem and the accepted answer is no more relevant on the latest version of VSCode (I'm using 1.74.3). It will throw an error something like below.

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in #terminal.integrated.profiles.windows# and setting its profile name as the default in #terminal.integrated.defaultProfile.windows#. This will currently take priority over the new profiles settings but that will change in the future.

The issue is, there are two types of bash application available in Git,

  1. git-bash.exe (opens up in a separate window)
  2. bash.exe (opens up in VSCode terminal window)

The bash.exe is located inside /bin folder.

It requires below config in the settings.json

 "terminal.integrated.profiles.windows": {
    "Bash": {
      "path": "C:\\Program Files\\Git-2.35.1.2\\bin\\bash.exe"
    }
 }

Upvotes: 3

Machado
Machado

Reputation: 10404

For those using Git installed via Scoop, just use the Scoop's installation folder path:

"terminal.integrated.shell.windows": "${env:USERPROFILE}\\scoop\\apps\\git\\current\\bin\\bash.exe",

Upvotes: 1

Indrajeet Gour
Indrajeet Gour

Reputation: 4500

Not sure about all but in my case, git bash location is changed into the appdata instead of programming file, so you can use same as mentioned:

"terminal.integrated.shell.windows": "C:\\Users\\{user_name}\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",

Upvotes: 0

Hasan Gokce
Hasan Gokce

Reputation: 731

My Solution:

  1. Open settings

  2. Deactivate: Windows Enable Conpty

Windows Enable Conpty

Upvotes: 6

Rushikeshkaralkar
Rushikeshkaralkar

Reputation: 11

i was also face this issue but i solved this issue

change path of git bash

"terminal.integrated.shell.windows": "D:\Program Files\Git\bin\bash.exe"

and uncheked legacy console check box in cmd Image of cmd

Upvotes: 1

Aadn
Aadn

Reputation: 113

I was infact looking for the solution to this exact problem. @JBD said it correctly however I would just like to add that the git-bash.exe file is kept seperate in the normal program folder of git.

{
    "terminal.integrated.shell.windows": "D:\\Program Files\\Git\\git-bash.exe" 
}

but what you need to link within vs Codes settings is a different file which will enable git bash to run within the vs code terminal. The path to that is in the "bin" folder within the "Git" folder.

{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe" 
}

This will allow your git bash to run from within the terminal window of VS Code

Upvotes: 2

Related Questions