Bash – Using Git Bash terminal in VS Code – how to force it to open internally

bashgitterminalvisual-studio-code

So I am fairly new to pretty much everything.

I follow Brad from YT channel Traversy Media and am adapting his stack – slowly but surely.

I use VS Code as my editor and Git Bash as my terminal.

When he or anyone else I find on Google use bash in VS Code it always opens internally.

VS Code offers a shortcut Ctrl+Shift+C to open it externally and a shortcut Ctrl+` (or in my case Ctrl+F1) to open it internally.

In my case it opens it externally with both shortcuts as well as with menu View->Terminal.

In VS Code it still takes up space at bottom meant for the terminal, except I can't type anything in it. It looks like this:
Two internally opened "terminals" with split view in VS Code (and this only happens when I open them internally. If I open them externally, they just open as you'd expect, without opening these useless panel at the bottom of VS Code.

It instead opens them like this: Both opened externally

My JSON Settings are these:

{
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
  "workbench.colorTheme": "Monokai",
  "workbench.colorCustomizations": {
    "[Monokai]": {
      "tab.activeBackground": "#999999",
      "tab.activeForeground": "#333333"
    }
  },
  "emmet.triggerExpansionOnTab": true,
  "editor.fontSize": 14,
  "editor.wordWrap": "on",
  "editor.codeActionsOnSave": {},
  "editor.tabSize": 2,
  "php.suggest.basic": false,
  "php.validate.executablePath": "C:\\xampp\\php\\php.exe", //for linting
  "php.validate.run": "onSave", //change to onType if need be
  "explorer.confirmDelete": false,
  "beautify.language": {
    "js": {
      "type": [
        "javascript",
        "json",
        "jsonc"
      ],
      "filename": [
        ".jshintrc",
        ".jsbeautifyrc"
      ]
    },
    "css": [
      "css",
      "scss"
    ],
    "html": [
      "htm",
      "html"
    ]
  },
  "beautify.config": {
    "indent_size": 2,
    "indent_char": " ",
    "css": {
      "indent_size": 2
    }
  },
  "window.zoomLevel": 0,
  "workbench.colorCustomizations": {
    "gitDecoration.addedResourceForeground": "#f45342",
    "gitDecoration.modifiedResourceForeground": "#3888d8"
  },
  "workbench.settings.useSplitJSON": true,
  "files.trimTrailingWhitespace": true,
  "minify.minifyExistingOnSave": true
}

Can't find the solution to this anywhere on Google..

Can anyone provide some insight?

Best Answer

It seems adding "terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe" to Settings is the old way and doesn't work as expected.

Delete all lines related to bash from Settings JSON (check User, Workspace and Folder Settings to be sure) and save the file.

Then just open Command Palette (Ctrl + Shift + P) and type in

Select Default Shell

and choose bash from there.

Now all you have to do is restart VS Code and terminal will be running as expected.

For shells that aren't in your %PATH%, see the other answers.

See the complete Visual Studio Code shell reference.

Related Question