You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过msys2_shell.cmd传递参数设置mintty终端尺寸?

解决MSYS2通过msys2_shell.cmd传递终端尺寸参数的问题

正确的终端命令示例

直接在bash终端执行以下命令,即可打开指定尺寸的MSYS2终端:

msys2_shell.cmd -defterm -here -no-start -s 125,38

或者使用长参数格式:

msys2_shell.cmd -defterm -here -no-start --size=125,38

Python脚本中的调用示例

如果要在Python脚本中实现,使用subprocess模块的代码如下:

import subprocess

# 通过msys2_shell.cmd打开指定尺寸的终端
subprocess.run([
    "msys2_shell.cmd",
    "-defterm", "-here", "-no-start",  # msys2_shell自身的必要参数
    "-s", "125,38"  # 传递给mintty的尺寸参数
])

简化方案:直接调用mintty

如果不需要通过msys2_shell.cmd加载完整的shell初始化环境,直接调用mintty更简单,避免参数传递的麻烦:

import subprocess

# 直接打开指定尺寸的mintty终端
subprocess.run(["mintty", "-s", "125,38"])

关键注意事项

  • msys2_shell.cmd需要先处理自身的参数(如-defterm、-here),mintty的参数必须放在这些参数之后
  • 尺寸参数必须用逗号分隔行列(125,38),而非x(虽然mintty本身支持x,但通过msys2_shell.cmd传递时逗号格式更可靠)
  • -no-start参数用于避免终端启动后自动打开默认shell的额外窗口,确保只打开指定尺寸的窗口

内容的提问来源于stack exchange,提问作者JohnA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 15:03:13