VS Code 从 powershell 打开新终端 [英] VS Code Open new terminal from powershell

查看:55
本文介绍了VS Code 从 powershell 打开新终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS 代码(Windows 10)

VS Code (Windows 10)

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

What I want to achieve from ps1 script :

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

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

I created a powershell script that I run from default opened terminal. Now I'd like to open a new terminal tab from first one.

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

Can I fire a vs code command shortcut (Ctrl+`) or a vs code command palette (Ctrl+Shift+P) from terminal ?

推荐答案

这是我解决问题的方法.

Here is how I solved my problem.

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

I created a VS Code extension and I used the 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

这篇关于VS Code 从 powershell 打开新终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆