从 CLI 启动 Windows 终端并将可执行命令传递给 运行
Start Windows Terminal from the CLI and pass in an executable command to run
我可以开始 Windows Terminal with wt
. I have read the Windows Terminal documentation on command-line arguments,它只包括传递一个用于设置终端面板的参数,而不是传递实际的可执行命令。
例如,一个最小的可重现示例:需要 Windows 安装终端:
在 Windows 中打开 CMD 提示符并输入:
dir | wt
这会启动 Windows 终端,但它不会收到 dir
命令。如何将可执行命令传递给 Windows 终端?
使用
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k dir
可以省略new-tab
(默认命令)
省略-d "%cd%"
好像等同于-d "%USERPROFILE%"
.
如果您的默认配置文件设置为 cmd.exe 配置文件,您可以省略 -p "Command Prompt"
。检查以下文件 (Windows) 中的 wt
设置:
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
尝试比 dir
更复杂的命令,例如
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k "dir & type "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json""
请同时检查 How to pass commands into the shell opened in new Windows Terminal 问题。
我可以开始 Windows Terminal with wt
. I have read the Windows Terminal documentation on command-line arguments,它只包括传递一个用于设置终端面板的参数,而不是传递实际的可执行命令。
例如,一个最小的可重现示例:需要 Windows 安装终端:
在 Windows 中打开 CMD 提示符并输入:
dir | wt
这会启动 Windows 终端,但它不会收到 dir
命令。如何将可执行命令传递给 Windows 终端?
使用
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k dir
可以省略
new-tab
(默认命令)省略
-d "%cd%"
好像等同于-d "%USERPROFILE%"
.如果您的默认配置文件设置为 cmd.exe 配置文件,您可以省略
-p "Command Prompt"
。检查以下文件 (Windows) 中的wt
设置:%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
尝试比 dir
更复杂的命令,例如
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k "dir & type "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json""
请同时检查 How to pass commands into the shell opened in new Windows Terminal 问题。