有没有办法在Visual Studio代码中使用键绑定Ctrl + Shift + c时更改打开的shell?

时间:2015-05-01 07:50:44

标签: visual-studio-code

我在键盘快捷键设置中注意到了这段代码。 { "key": "ctrl+shift+c", "command":"workbench.action.terminal.openNativeConsole" },

我想知道,我可以将其更改为打开Powershell而不是打开cmd.exe吗?

3 个答案:

答案 0 :(得分:5)

从v1.1.0开始,我们现在可以配置外部shell。

在版本1.6.1之前,只有一个设置。

"externalTerminal.windowsExec": "powershell"

从版本1.6.1开始,有一个外部和内部终端设置。使用值“%COMSPEC%”,可以改为更改其COMSPEC环境变量。

// The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu), prefer C:\Windows\sysnative over C:\Windows\System32 to use the 64-bit versions.
"terminal.external.windowsExec": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",

// The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu), prefer C:\Windows\sysnative over C:\Windows\System32 to use the 64-bit versions.
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
但是,我发现它打开了32位Powershell.exe。对我来说,没有设置执行策略。所以我使用以下内容设置它......

我提升了我的权限(Powershell的sudo版本):

Start-Process Powershell -Verb Runas

然后,在新升级的Powershell窗口中:

Set-ExecutionPolicy RemoteSigned

答案 1 :(得分:3)

目前,自定义更倾向于更改触发操作的键/条件,而不是添加新操作。

能够创建自定义操作也很棒 - 而且Visual Studio Code团队有兴趣听取User Voice site上的想法。

我添加了suggestion for custom actions

答案 2 :(得分:0)

截至2016年2月,仍然没有设置,但您可以使用CodeShell扩展程序,安装后使用Ctrl-Alt-P在项目文件夹的根目录下启动PowerShell窗口。