How do I use Bash on Windows from the Visual Studio Code integrated terminal?

前端 未结 17 1796
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 00:28

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?

相关标签:
17条回答
  • 2020-11-28 00:52

    I followed this tutorial from Paul DeCarlo to use the Bash from the Windows Subsystem for Linux (WSL) instead of what comes with Git Bash for Windows. They are the same steps as above in the answer, but use the below in your User Settings instead.

    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe",

    This worked for me the first time... which is rare for this stuff.

    0 讨论(0)
  • 2020-11-28 00:53

    You no longer need to type in bash.exe path manually. This answer is deprecated. Now you can switch to bash directly. Just make sure you have git installed.


    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 -

    0 讨论(0)
  • 2020-11-28 00:53

    Latest VS code :

    • if you can't see the settings.json, go to menu File -> Preferences -> Settings (or press on Ctrl+,)
    • Settings appear, see two tabs User (selected by default) and Workspace. Go to User -> Features -> Terminal
    • Terminal section appear, see link edit in settings.json. Click and add "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    • Save and Restart VS code.

    Bash terminal will reflect on the terminal.

    0 讨论(0)
  • 2020-11-28 00:58

    I had already set up lots of conda environments on WSL (Bash on Ubuntu on Windows), so I wanted to use the same Bash installation on Visual Studio Code.

    To do that, I just had to specify the path of this particular Bash executable (instead of the Git-Bash) on Visual Studio Code's settings:

    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"


    PS: to make sure where your Ubuntu on Bash executable is installed on your Windows machine, open the Command prompt (search: cmd) and run:

    where bash.exe

    0 讨论(0)
  • 2020-11-28 00:59

    I happen to be consulting for a Fortune 500 company and it's sadly Windows 7 and no administrator privileges. Thus Node.js, Npm, Visual Studio Code, etc.. were pushed to my machine - I cannot change a lot, etc...

    For this computer running Windows 7:

    Below are my new settings. The one not working is commented out.

    {
        "update.channel": "none",
        "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
        //"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
    }
    
    0 讨论(0)
提交回复
热议问题