You can add Windows shell extensions for launching MSYS2 Bash sessions in a target directory.
For right-clicking the background of an open folder, use the command
C:\msys64\usr\bin\mintty --icon /msys2.ico /usr/bin/env CHERE_INVOKING=1 /usr/bin/bash --login
For right-clicking a folder, use the command
C:\msys64\usr\bin\mintty --icon /msys2.ico /bin/sh -lc 'cd "%V"; /usr/bin/env CHERE_INVOKING=1 bash --login'
These will launch Bash as if you had manually cd
'ed to the specified directory.
Importantly, Bash completion will work.
They key is launching Bash with CHERE_INVOKING=1
set in the target directory.
That makes the second command more involved,
since it needs to descend into the selected directory (%V
) first.
mintty
will correctly interpret the UNIX style file paths,
and in Windows fashion the executable extensions are optional.
The --icon
argument and its value is optional.
The attached .reg
file creates the extensions for path to mintty
above.
Adjust the path accordingly before executing.
An older solution I knew of,
C:\msys64\usr\bin\mintty.exe /bin/sh -lc 'cd "$(cygpath "%V")"; exec bash'
whose origin I have forgotten, created a functional shell but did not initialise Bash completion.