VS Code integrated terminal, how to choose git bash as a default? - visual-studio-code

My VS Code used to show default intagrated terminal as a git bash (I chose it in settings). But after last update August 2021, when I open VS Code I see windows Powershell, but when you click plus it adds git bash. Earlier in both cases there was git bash
Can you give any advise how to choose git bash to be shown when vs code starts?
"terminal.integrated.defaultProfile.windows": "Git Bash",

At first open command palette by pressing below command
ctrl + shift + p
and search for
open setting (json)
click here
then change your setting.json file as below
click here
at last reopen visual studio code.

Related

Git-Bash in Visual Studio Code from the D drive

I am trying to use Git Bash as a terminal in Visual Studio Code, however I am not able to find it in the terminal profiles. The option for Git Bash doesn't appear in the available terminals. I have installed Bash already. However I did it in the D drive. Is there a way to make git-bash available to choose as a terminal or even make it the default one from the D drive?
You can create your own profile in the setting.json file and set the default terminal profile to it, like so (for Windows):
"terminal.integrated.profiles.windows": {
"My Git Bash":{
"path": "D:\\GitbashLocation\\git-bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "My Git Bash",
Note that you can name your profile whatever you want. You may also need to restart Visual Studio Code after defining your profile so it detects it when you specify it in the terminal.integrated.defaultProfile.windows setting.
I was also struggling with the same but finally got it fixed with thanks to the final bit of help needed from #Timothy G's answer, with the help of other posts here on stack as well.
Let me just post a step-by-step solution adding to the #Timothy G's answer below, JIC if you're still struggling with it and also for future visitors.
Note: I'm using VS Code Insiders build (Version: 1.64.0-insider(user setup)) on Windows, but should work for other builds as well.
Since you have already downloaded git bash, ignore the 1st step.
Download git bash from the https://git-scm.com/download/win.
Open VS Code ⟹ File ⟹ Preferences ⟹ Settings. (Ctrl + ,).
There will be a search bar on top.
Search for terminal.integrated.profiles.windows.
A result will come up that would look like this
Terminal › Integrated › Profiles: Windows
The Windows profiles to present when creating a new terminal via the terminal dropdown. Use the source property to automatically detect the shell's location. Or set the path property manually with an optional args.
Set an existing profile to null to hide the profile from the list, for example: "Ubuntu-20.04 (WSL)": null.
Edit in settings.json
Click on Edit in settings.json.
Then another window will pop up next to the Settings tab called settings.json
Copy and paste this inside the settings.json. Remember to set the “path” to your git bash.exe in the bin folder
You can remove the first two lines if you don't need it and do Ctrl + S to save the JSON settings.
{
"workbench.colorTheme": "Default Dark+",
"files.autoSave": "afterDelay",
"terminal.integrated.profiles.windows": {
"My Git Bash":{
"path": "I:\\Projects\\git\\bin\\bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "My Git Bash",
}
After adding the above, select the “Settings” tab again and search for terminal.integrated.defaultProfile.windows
Then you'll be presented with a terminal feature like this with a drop-down.
Terminal › Integrated › Default Profile: Windows
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.
Under the drop-down, select the profile My Git Bash then you're
all set.
Then got to ⟹ View ⟹ Terminal. (Ctrl + `)
It should now show up with the bash terminal. If it doesn't, restart VSC and it'll work for sure.
In order to make Timothy G.'s answer work, first, add the new profile as described in the VSCode documentation:
Step 1: "To create a new profile, run the Terminal: Select Default Profile command and activate the configure button on the right side of the shell to base it on. This will add a new entry to your settings that can be tweaked manually in your settings.json file."
https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-profiles
Type in a new name in the input box after you click the "configure" button. This will create a new profile in settings.json with your new name cloned from an existing profile (against which you clicked the "configure" button).
Step 2: Go to the settings.json file. You will see the profile with your new name added there. Update it with Timothy G's settings. Here is how mine looks like:
{
"My Git Bash": {
"path": "D:\\Git\\bin\\bash.exe",
"icon": "terminal-bash"
}
"terminal.integrated.defaultProfile.windows": "My Git Bash"
}
Step 3: Save and restart VSCode. The next time the terminal will open with Git Bash.

Redefine Terminal does not work when starting VS Code

I can live with it, but...
I have changed the terminal from PowerShell to git bash in the settings:
"terminal.integrated.defaultProfile.windows": "Git Bash"
This does its job. When I create a new terminal, it is git bash by default.
However, when I start Visual Studio Code, it opens with a PowerShell terminal. (All new terminals are git bash terminals.)
To set the default terminal in VS Codem , you should follow this steps:
Open VS Code
Press CTRL+Shift+P / ⇧⌘P and search for terminal select default shell
Make your selection and press enter (In my case I chose Git Bash)
All of your new terminals will now default to your choice 🎉
I hoped this helped you.

How to Add Git Bash to VsCode

It is not showing Git Bash Option in while selecting terminal in VsCode
Make sure you have already installed Git for Windows
In VS Code, go to Command Palette (⇧⌘P) with Terminal: Select Default Profile or Terminal: Select Default Shell in older versions, then select available shell in this case, Git Bash, in the dropdown list.
Click on + sign next to terminal list as shown below:
At this point, the Git Bash should be successfully added.
PS. The list might disappear if the VS Code is closed. Only the default shell will show up. You have to do the steps above again.

How do I get around the verified bug in Windows 1903 and launch the VSCode integrated terminal?

I just did a fresh install of Windows 10 Pro version 1903 build 18362.116 and Visual Studio Code. Now the integrated terminal only launches externally.
Pressing Ctrl + ~ results in this.
What am I missing? How do I get it to open integrated again?
EDIT
After working with VSCode team it is a verified bug. See the Github issue here. I posted the workaround as an answer here.
OK, worked through this one in VSCode repo issues.
For now, until it's fixed, turn off ConPTY integration in the User Settings.
💥💥💥
The issue now says use legacy console. To change the setting open a cmd prompt. Right click the title to bring up properties.
Then Uncheck 'Use legacy console'
To change the integrated terminal on Windows, you just need to change the terminal.integrated.shell.windows line:
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Check if "terminal.integrated.shell.windows" has value "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right.
Remove this line.
Ctrl + ~ will now open integrated terminal of VSCode.
If the above solution doesn't work then can you try below values and check if it works for you:
// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
From the Command Palette (Ctrl+Shift+P), use the View: Toggle Integrated Terminal command.
Try custom shortcut:
[
{
"key": "ctrl+`",
"command": "workbench.action.terminal.toggleTerminal"
}
]
Had this problem fixed. Found the solution from the VS Code support.
for error:
Terminal exits with code 3221225786 (or similar)#
"This can happen when you have legacy console mode enabled in conhost's properties. To change this, open cmd.exe from the start menu, right-click the title bar, go to Properties and under the Options tab, uncheck Use legacy console."
source: VS Code docs

How to integrate git bash in visual studio code

How to integrate git bash in visual studio code? I typed " open user setting " then I am getting this window:
VSCode has support for git built in.
You might need to check that the directory containing the git executable is on your PATH environment variable. Alternatively, in settings.json, set git.path, for example:
{
"git.path": "d:/opt/git-for-windows-2.23.0/bin/git.exe"
}
You also need to install git first.
Following steps have to be followed to integrate Git Bash with Visual Studio Code:
Step-1
You have to open settings by File->Preferences->Settings or by pressing Ctrl+, AND click on the Open Settings(JSON) icon on the top right corner of vs code editor
Step-2
On clicking, you will see the settings page. You have to copy:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
and paste at the last of all settings. Make sure that you have installed git bash on your computer.
Step-3
And that’s all when you will reopen VS Code then you will see that Git Bash has been integrated. Now you can run Git Bash commands directly in VS Code.