Gar*_*han 3 windows msys msys2 windows-terminal
[编辑添加:]事实证明,这里的实际问题是我犯的一个无脑的打字错误。我实际问题的答案是“是的,如果你不是白痴,你只需做显而易见的事情,它就会起作用”。我接受基本上是这样说的答案,但也许实际上应该删除这个问题。
我的雇主在 Windows 上进行软件开发的标准设置涉及使用 MSYS。(传统的 MSYS 或 MSYS2。)有没有办法在新的 Windows 终端中运行其中任何一个的 shell?
sh.exe传统的 MSYS 有一个 Windows 批处理脚本,可以安排在运行它的任何终端内执行。因此,您可能认为在 WT 中创建一个新的配置文件profiles.json,使用"commandline": "path\to\sh.exe",就可以解决问题。唉,不:如果我这样做并向 WT 询问该类型的终端,我会得到一个普通的旧cmd提示。(从 开始C:\WINDOWS\System32。)[编辑添加:] 呃,不,唉,是的:如果我这样做,那么它基本上可以工作,但是这会出现一些错误,而接受的答案是正确的。
您运行以获得 MSYS2 提示符的是 Windows 可执行文件,而不是传统 MSYS 中的批处理脚本,但它也启动自己的sh.exe. 同样的事情也会发生。
我想这里发生的事情是 MSYSsh.exe只是期望通过 stdin 和 stdout 进行交互,而适合直接从 WT 运行的可执行文件需要了解相当复杂的 Microsoft 控制台 API 或类似的东西。
我也尝试过以下方法,但没有什么乐观的态度,也没有成功(它们都产生与上面相同的结果):
"commandline": "cmd path/to/sh.exe"
"commandline": "cmd /c path/to/sh.exe"
"commandline": "cmd path/to/msys2_shell.cmd"
"commandline": "cmd /c path/to/msys2_shell.cmd"
Run Code Online (Sandbox Code Playgroud)
有没有什么方便的方法可以让 MSYS shell 在 Windows 终端中运行?
MSYS2 有自己的指南将 MSYS2 添加到 Windows 终端。它使用msys2_shell.cmd而不是手动运行 shell。
Usage:
msys2_shell.cmd [options] [login shell parameters]
Options:
-mingw32 | -mingw64 | -ucrt64 | -clang64 | -msys[2] Set shell type
-defterm | -mintty | -conemu Set terminal type
-here Use current directory as working
directory
-where DIRECTORY Use specified DIRECTORY as working
directory
-[use-]full-path Use full current PATH variable
instead of trimming to minimal
-no-start Do not use "start" command and
return login shell resulting
errorcode as this batch file
resulting errorcode
-shell SHELL Set login shell
-help | --help | -? | /? Display this help and exit
Any parameter that cannot be treated as valid option and all
following parameters are passed as login shell command parameters.
Run Code Online (Sandbox Code Playgroud)
我认为手册本身是不言自明的。这里重要的标志是-no-start和-defterm。但在这里,我想添加更多标志。我添加的是-here指南推荐的,并且-shell,因为我想选择其他外壳。您可以根据需要自定义它。
C:\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell zsh
Run Code Online (Sandbox Code Playgroud)
所以,JSON 配置文件将是
Usage:
msys2_shell.cmd [options] [login shell parameters]
Options:
-mingw32 | -mingw64 | -ucrt64 | -clang64 | -msys[2] Set shell type
-defterm | -mintty | -conemu Set terminal type
-here Use current directory as working
directory
-where DIRECTORY Use specified DIRECTORY as working
directory
-[use-]full-path Use full current PATH variable
instead of trimming to minimal
-no-start Do not use "start" command and
return login shell resulting
errorcode as this batch file
resulting errorcode
-shell SHELL Set login shell
-help | --help | -? | /? Display this help and exit
Any parameter that cannot be treated as valid option and all
following parameters are passed as login shell command parameters.
Run Code Online (Sandbox Code Playgroud)
对于 GUID 字段,您可以在 PowerShell 中生成自己的 GUID 字段,或者使用像这样的[guid]::NewGuid().Guid在线服务。它只是表明此配置文件与其他可能具有相同名称的配置文件不同。
对于最新版本的 Windows Terminal,您不需要手动编辑 JSON 文件,它还会为您生成 GUID。只需单击“添加新配置文件”并指定“命令行”字段即可。
| 归档时间: |
|
| 查看次数: |
9987 次 |
| 最近记录: |