如何通过在Powershell(Windows终端)中运行特定命令来打开新选项卡?
我想要的是打开具有 Powershell 并运行特定命令的新选项卡(在我的情况下为“npm run local”)。
我期待这会奏效,
wt -w 0 -p "Windows Powershell" npm run local
但是,它给出了错误,
[error 0x80070002 when launching `npm run local']
有可能吗?
*注意:我做了很多研究,也阅读了官方文档,但我找不到方法。
回答
我从 Windows 终端开发人员那里找到了最佳/推荐的解决方案。
在 GitHub 上回答
对于命令提示符和 Powershell。
wt --window 0 -p "Windows Powershell" -d . powershell -noExit "npm run local"
仅适用于 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"
THE END
二维码