【问题标题】:VS Code Open new terminal from powershellVS Code 从 powershell 打开新终端
【发布时间】:2018-06-22 07:58:29
【问题描述】:

VS 代码(Windows 10)

我想通过 ps1 脚本实现的目标:

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

我创建了一个我从默认打开的终端运行的 powershell 脚本。现在我想从第一个打开一个新的终端选项卡。

我可以从终端触发 vs 代码命令快捷方式 (Ctrl+`) 或 vs 代码命令面板 (Ctrl+Shift+P) 吗?

【问题讨论】:

标签: powershell terminal visual-studio-code


【解决方案1】:

这是我解决问题的方法。

我创建了一个VS Code extension,并使用了extension 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

【讨论】:

  • 对于看似简单的任务还是有点复杂
猜你喜欢
  • 1970-01-01
  • 2022-01-09
  • 1970-01-01
  • 2023-02-15
  • 2021-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多