VS Code Hack: How to Change the Default Terminal from PowerShell to Bash

By default, the integrated terminal in Visual Studio Code (VS Code) on Windows uses PowerShell as the default shell. However, if you prefer to use Bash instead, you can easily change the default terminal shell with a simple configuration change.

Here’s how to do it:

  1. Open VS Code and click on the “Settings” icon in the left-hand toolbar (or press Ctrl+,) to open the VS Code settings editor.
  2. Search for the setting “terminal.integrated.shell.windows” and click the “Edit in settings.json” link to open the settings.json file.
  3. Add the following line to the settings.json file, replacing the path to bash.exe with the actual path to your Bash executable:json "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe" If you don’t know the path to your Bash executable, you can open Git Bash, type which bash in the terminal, and copy the output into the settings.json file.
    Note that you’ll need to use double backslashes in the file path to escape the backslashes.
  4. Save the settings.json file and close the editor.
  5. Open a new terminal in VS Code by pressing Ctrl+Shift+ `or selecting “Terminal” > “New Terminal” from the VS Code menu.You should now see that the terminal is running Bash instead of PowerShell.

That’s it! Now you can enjoy using Bash as your default shell in the VS Code terminal. If you ever want to switch back to PowerShell, you can still do so by clicking on the dropdown arrow in the terminal window and selecting “PowerShell” from the list of available shells.

If you want to customize the Bash terminal further, you can also create a .bashrc or .bash_profile file in your home directory (usually C:\Users\<username> on Windows) and add your own customizations to it. This file will be sourced every time you open a new Bash terminal in VS Code.

Happy coding!

Leave a Reply