Visual Studio Code on Windows uses PowerShell by default as the integrated terminal. If you want to use Bash from Visual Studio Code, what steps should be followed?
VS Code provides excellent extensions for Bash scripting.
Install Git from https://git-scm.com/download/win
Open Visual Studio Code and press and hold Ctrl + ` to open the terminal.
Open the command palette using Ctrl + Shift + P.
Type - Select Default Profile
Select Git Bash from the options
Click on the + icon in the terminal window
The new terminal now will be a Git Bash terminal. Give it a few seconds to load Git Bash
You can now toggle between the different terminals as well from the dropdown in terminal.
You no longer need to type in bash.exe path manually. This answer is deprecated. Now you can switch to bash directly, if you have git installed in the default path. If you installed git to a different path you need to use the below solution.
Install Git from https://git-scm.com/download/win.
Then open Visual Studio Code and open the command palette using Ctrl + Shift + P. Then type "open user setting", and then select "Open User Settings" from the drop down menu.
Then this tab will open up with default settings on left and your settings on the right:
Now copy this line of code to your own settings page (the pane on the right hand side) and save -
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
Note: "C:\\Program Files\Git\bin\bash.exe"
is the path where the bash.exe
file is located from the Git installation. If you are using the Windows Subsystem for Linux (WSL) Bash shell, the path would be "C:\Windows\System32\bash.exe"
Now press Ctrl + ` to open up the terminal from Visual Studio Code. And you will have Bash -
Updated: Newer versions of Visual Studio Code have the Select Default Shell command in the terminal pull down menu:
Remember that it just lists the shells that are in your %PATH% environment variable. For shells that aren't in your path, see other answers.
Extra tip: when you start bash it will just execute .bashrc
, if you have initialization commands in .bash_profile
you must copy it to .bashrc
. It's essential for using Conda enviroments in Git Bash.
The easiest way now (at least from Visual Studio Code 1.22 on) is to type Shift + Ctrl + P to open the Command Palette and type:
Select Default Shell
Now you can easily select your preferred shell between the ones found in your path:
For shells that aren't in your %PATH%, see the other answers.
See the complete Visual Studio Code shell reference. There's lot of meaty stuff.
Press and hold Ctrl + ` to open the terminal.
Inside the terminal, type bash
to use Git Bash in the terminal.
Note: Make sure you have Git Bash installed on your machine.
If you wish to use PowerShell again, just type powershell
in the terminal. To use the Windows command line, type cmd
in the terminal.
The setting you choose will be used as your default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With