Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My new favorite way to launch MSYS2
@echo off
cd %~dp0
set MSYSTEM=%~1
set _TERM=%~2
set _SH=%~3
set _ARGS=%~4
REM If MSYSTEM is empty, uses MSYS.
REM Other valid values for MSYSTEM are MINGW32 and MINGW64.
if "x%MSYSTEM%" == "x" set MSYSTEM=MSYS
REM If _TERM is empty we use the default Windows terminal, not sure what it is called.
REM Another valid value is "mintty", but you can use a custom terminal too.
if "x%_TERM%" == "xmintty" set _TERM=usr/bin/mintty --option AppId=msys2 -i /msys2.ico
REM If _SH is empty or equal to "bash", we use an interactive, login bash shell.
REM Alternatively, you can use a custom shell.
if "x%_SH%" == "x" set _SH=usr/bin/bash --login -i
if "x%_SH%" == "xbash" set _SH=usr/bin/bash --login -i
start %_TERM% %_SH% %_ARGS%

Here are some example ways you can launch MSYS2 using msys2_env.bat:

  • MSYS2 MSYS Console
    • msys2_env
    • msys2_env MSYS "" bash
  • MSYS2 MSYS MinTTY
    • msys2_env "" mintty
    • msys2_env MSYS mintty bash
  • MSYS2 Win32 Console
    • msys2_env MINGW32
    • msys2_env MINGW32 "" bash
  • MSYS2 Win32 MinTTY
    • msys2_env MINGW32 mintty
    • msys2_env MINGW32 mintty bash

I'm thinking we would ship msys2_env.bat with several shortcuts that provide useful combinations like this.

What should we call the default Windows terminal? I called it "Console" in the examples above.

If people are excited about it, I could work on a pull request to make it part of MSYS2. If not, that's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.