且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Visual Studio Code 集成终端中选择不同类型的命令外壳

更新时间:2023-02-18 14:48:47

截至 2018 年 6 月 17 日,在更改集成命令外壳方面,Visual Studio Code 中的事情变得非常顺利.我在这里列出了所有选项:

  1. 随时随地选择不同的命令外壳 - 命令外壳的名称本身就是将当前命令外壳切换到目标命令外壳的命令.例如,假设我的集成命令 shell 当前正在显示 Bash,我想立即切换到 PowerShell.然后键入命令 powershell,按 Enter,命令外壳将更改为 PowerShell.同样,它适用于您产品中安装的所有其他类型的命令 shell.
  2. 命令外壳的更多实例 - 只需按 Ctrl + Shift + `(反勾号).每次按下键盘快捷键组合时,都会添加一个新的命令外壳实例.
  3. 更改默认命令外壳类型的配置 - 在 Visual Studio Code 中按 F1 并键入或选择 Terminal: Select Default Shell 如图所示在下面的快照中.

选择后,然后选择您选择的默认命令外壳以永久更改设置:

I looked at this link which talks about changing the default command shell in the integrated terminal of Visual Studio Code. I was successfully able to change it to Git Bash using the below setting in the settings.json file. You can open the settings.json file by pressing the Ctrl + , key combination or menu FilePreferencesSettings menu:

{
   "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}

There is a + sign in the integrated terminal with the help of which you can have multiple terminals running parallelly as shown in the screenshot below:

I want to load a Git Bash shell in terminal # 1, Windows PowerShell in terminal # 2, etc. What is the relevant configuration to achieve the same?

As of June 17 '2018, things have become really smooth in Visual Studio Code when it comes to changing the integrated command shell. I'm enlisting all the options here:

  1. Select a different command shell on the go - Name of the command shell is itself a command to switch the current command shell to the target command shell. For example, let's say my integrated command shell is currently showing Bash, and I want to switch to PowerShell right away. Then type the command powershell, press Enter and the command shell changes to PowerShell. Similarly it works for all other types of command shells installed in your product.
  2. More instances of command shell - Just press Ctrl + Shift + `(back-tick). Every time you press the keyboard shortcut combination, a new instance of the command shell will get added.
  3. Change the configuration of default command shell type - Press F1 in Visual Studio Code and type or select Terminal: Select Default Shell as shown in the snapshot below.

Once selected, then choose the default command shell of your choice to change the settings permanently: