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

7,715

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.

Share:
7,715

Related videos on Youtube

s3c
Author by

s3c

Intro I've been studying at Faculty of Mathematics and Physics, University of Ljubljana, Slovenia from 2008 to 2012. After that and additional 6 years of doing manual labour (wood cutting and later roofing) I finally decided, to do what I loved since I found out about it - programming. 2021 (June) PHP 8.x rocks! Still hadn't gotten around with Laravel much, because the company wasn't ready for the move to the framework, and I'm really short on time in my private life with my partner, family, chess, sudoku-variant puzzles and sports. Partially rewritten our backend for websites using a MVC structure. Started with more and more OOP this year. I figured out GIT and made a GIT server with self-hosted GitLab for our company (basically forced everyone to start using it). Figured out SASS and modularized our styling sources, for them to later be compiled into one bundle. Did pretty much the same thing for scripts using tsconfig.json, but still staying with ES6 vanilla JavaScript and not writing any TypeScript. The most improvement made for our websites' discoverability was in the last two months when I dived deep into modern SEO rules (including multi-language). Creating my own Route class (imitating that of Laravel) helped with that a lot, along with dissecting all our spaghetti code into MVC. Using Lighthouse on web.dev I've upped our game for Performance/Accessibility/Best Practices/SEO from 20-70/40-50/50-70/40-60 to 80-95/100/100/100 every time. Feels like an achievement. 2020 (July) SO. MUCH. TO. LEARN. I've been using ECMAScript6+ for the last half a year, and dropped jQuery completely. Also improving my understanding and usage of Three.js library. PHP-wise I'm adopting the latest versions (currently 7.4) and eagerly awaiting PHP 8. Not the least mentioning-worth skill I'm improving on is Laravel (with no prior knowledge). Oh, and I keep forgetting my projects in Xamarin.Forms (XAML, C#) - I make them work, but not really sure how. Oops. 2019 (March) I've gathered loads of experiences in HTML, CSS, PHP and JS, but the more I know, the more I see how clueless I am. As I develop web applications I further develop myself and will continue to do so in the future. 2018 (September) I was lucky enough for a company called 8000plus d.o.o. to hire me without any experiences or knowledge, just based on my personality and whom I presented myself as - an enthusiast who will programme with or without them. Hopefully I'll remember to update this description every year.

Updated on September 18, 2022

Comments

  • s3c
    s3c over 1 year

    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?

    • s3c
      s3c about 5 years
      Please elaborate. Is there a different type of formatting for text than just plain text written in directly? Or did you perhaps mean, that my "code" should not be an image?
    • Seth
      Seth about 5 years
      How did you install git? Did you choose to only have MingW available or did you integrate it so you can use it from a cmd?
    • s3c
      s3c about 5 years
      If I open cmd and type in bash and press Enter, it changes colorization and adds $ before input. If that doesn't answer your question, then I need to go through installation process again, since I don't remember MingW option.
  • s3c
    s3c almost 5 years
    "terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe", Is this what I already have in my settings not enough?
  • V. Rubinetti
    V. Rubinetti about 4 years
    FWIW, my error was that i was setting "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-bash.exe", which is the wrong .exe. It should be "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe".