我想要的是打开具有 Powershell 并运行特定命令的新选项卡(在我的情况下为“npm run local”)。
我期待这会奏效,
wt -w 0 -p "Windows Powershell" npm run local
但是,它给出了错误,
[error 0x80070002 when launching `npm run local']
有可能吗?
*注意:我做了很多研究,也阅读了官方文档,但我找不到方法。
运行Get-Command npm显示这npm实际上是npm.cmd一个 CMD 解释脚本,而不是 PowerShell。当直接在命令行运行时,PowerShell 可以关闭扩展,但是当通过 Windows 终端配置文件传递时,扩展似乎是必需的:
wt -w 0 -d . -p "Windows PowerShell" npm.cmd init
wt -w 0 -d . -p "Command Prompt" npm.cmd init
Run Code Online (Sandbox Code Playgroud)
(编辑: -d .根据您的评论添加。如果没有它,正如您所指出的,它将始终默认为该%userprofile%目录)。
也就是说,从您的评论来看,您的用例似乎是在流程完成后保持选项卡打开。在这种情况下 ...
wt -w 0 -d . -p "Windows PowerShell" cmd /k npm run local
wt -w 0 -d . -p "Command Prompt" cmd /k npm run local
Run Code Online (Sandbox Code Playgroud)
我从 Windows 终端开发人员那里找到了最佳/推荐的解决方案。
对于命令提示符和 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"
Run Code Online (Sandbox Code Playgroud)
对于命令提示符
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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
426 次 |
| 最近记录: |