windows-terminal - 如何通过在 Powershell(Windows 终端)中运行特定命令来打开新选项卡?

标签 windows-terminal

我想要的是打开具有 Powershell 并运行特定命令的新选项卡(在我的情况下为“npm run local”)。
我期待这会奏效,wt -w 0 -p "Windows Powershell" npm run local但是,它给出了错误,[error 0x80070002 when launching `npm run local']
有可能吗?
*注意:我做了很多研究,也阅读了官方文档,但我找不到方法。

最佳答案

我从 Windows 终端开发人员那里找到了最佳/推荐的解决方案。
Answer on GitHub

For both Command Prompt and Powershell.

wt --window 0 -p "Windows Powershell" -d . powershell -noExit "npm run local"


Only for Powershell.

wt --window 0 -p "Windows Powershell" -d "$pwd" powershell -noExit "npm run local"



在我的情况下,在运行开发命令时最好地使用此功能
对于 Powershell
wt --window 0 -p "Windows Powershell" -d . powershell -noExit "npm run startMongo"`;  split-pane --horizontal -p "Windows Powershell" -d . powershell -noExit "npm run gulp-watch"`;  new-tab -p "Windows Powershell" -d . powershell -noExit "npm run local"
对于命令提示符
wt --window 0 -p "Windows Powershell" -d . powershell -noExit "npm run startMongo";  split-pane --horizontal -p "Windows Powershell" -d . powershell -noExit "npm run gulp-watch";  new-tab -p "Windows Powershell" -d . powershell -noExit "npm run local"

关于windows-terminal - 如何通过在 Powershell(Windows 终端)中运行特定命令来打开新选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67166275/

相关文章:

powershell - 从 PowerShell 脚本识别新的 Windows 终端

windows-subsystem-for-linux - 如何使用多个命令启动 Windows 终端

ssh - Windows 终端主题颜色 SSH

windows - 使用未执行的预定义命令运行 Windows 终端

bash - 如何将 bash 定义为默认的 Windows 终端命令处理器?

windows-terminal - 从 Windows 终端内以提升的权限打开 Windows 终端

windows-terminal - 执行命令行 exe 时使用 Windows 终端代替 cmd

json - Windows 终端 - 在保存时缩小我的配置是什么?

windows-subsystem-for-linux - 如何将 Windows Terminal 分成 8 个相等的 Pane "programmatically"?