[Python] Msys2 open a terminal from a python script with given rows and columns

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I am using MSYS2 and using a python script invoked from the command line in a bash terminal to open an other terminal with given rows and columns.

    Here's what I got so far:

    cmd = 'C:/msys64/msys2_shell.cmd ' \
    '-msys2 ' \
    '-shell bash ' \
    '-full-path ' \
    f'-where {next_dir} ' \
    '-mintty -s 125x38 '
    os.system(cmd)


    This does open a new terminal, but the "125x38" is ignored, the new terminal has the same size as the default MSYS2 size.

    If I do this mintty -s 125,38 or mintty --size=125,38 from the command line it works, the new terminal is the right size.

    So it seems that the parameters to mintty are not being passed by msys2_shell.cmd to mintty. I looked at that code, but I don't know windows scripting very well and so I can't figure it out https://github.com/msys2/MSYS2-packages/blob/master/filesystem/msys2_shell.cmd

    The SHELL_ARGS variable is somehow filled in but I don't understand how:

    "%WD%mintty" -i "/%CONICON%" -t "%CONTITLE%" "/usr/bin/%LOGINSHELL%" -l !SHELL_ARGS!


    Can someone please give an example of passing arguments to mintty from the command line to msys2_shell.cmd?

    I have tried a ton of these, some based on AI Gemini recommendations with no luck:

    C:/msys64/msys2_shell.cmd -mintty "--size=125,38"
    C:/msys64/msys2_shell.cmd -mintty "--size=125x38"
    C:/msys64/msys2_shell.cmd -mintty "-s 125x38"
    C:/msys64/msys2_shell.cmd -mintty -s 125x38
    C:/msys64/msys2_shell.cmd "-mintty -s 125x38"
    C:/msys64/msys2_shell.cmd -mintty -o -s 126x38
    C:/msys64/msys2_shell.cmd -mintty -o Geometry=125x38


    (many many more)

    Continue reading...

Compartilhe esta Página