我想要的是打开具有 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/