VS Code从Powershell打开新终端

Yva*_*ain 5 terminal powershell visual-studio-code

VS Code(Windows 10)

我想从ps1脚本中实现什么:

  • 打开4个终端标签
  • 首先运行python venv,然后运行django服务器
  • 第二个运行python venv,然后运行django shell
  • 第三次运行反应(纱线启动)
  • git和其他的第四普通powershell

我创建了一个Powershell脚本,该脚本从默认打开的终端运行。现在,我想从第一个打开一个新的终端标签。

我可以从终端启动vs代码命令快捷方式(Ctrl +`)或vs代码命令选项板(Ctrl + Shift + P)吗?

Yva*_*ain 3

这是我解决问题的方法。

我创建了一个VS Code 扩展并使用了扩展 API

// Create a terminal Window
const term = vscode.window.createTerminal("terminal_name");

// Write any powershell command
term.sendText("cd C:\\path\\to\\follow\\");

// Any other command
term.sendText("yarn start");

// Create a second terminal
const secTerm = vscode.window.createTerminal("second_terminal_name");

secTerm.sendText("cd C:\\another\\path\\to\\follow\\");

secTerm.sendText("py manage.py runserver");

// and so one
Run Code Online (Sandbox Code Playgroud)