Last active
February 2, 2019 13:15
-
-
Save Trucido/f324a644abbe1c27c21a290fc06d7a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Invoke MSYS bash directly without msys2_shell.cmd | |
function mbash { | |
param( | |
[Parameter(ValueFromRemainingArguments=$true)] | |
[string[]]$RemainingArgs | |
) | |
$msysArgs = @( | |
'MSYSTEM=MSYS' , 'MSYS2_PATH_TYPE=' , | |
'MSYSCON=' , 'MSYS=winsymlinks:nativestrict', | |
'LOGINSHELL=bash', '/usr/bin/bash' , | |
'--login', '-i' | |
) | |
if ($RemainingArgs) { $msysArgs += '-c',$RemainingArgs } | |
if ($null -ne ( | |
$msysPath = Get-ChildItem "${env:SystemDrive}\" -Recurse ` | |
-Depth 2 -Filter "msys2_shell.cmd" -EA 0 | | |
foreach { Split-Path $_.FullName -Parent } ) | |
) {} else { throw(New-Object([IO.DirectoryNotFoundException]'')) } | |
pushd $msysPath -ErrorAction:Stop # Push-Location | |
.\usr\bin\env.exe @msysArgs | |
popd # Pop-Location | |
} | |
# Invoke MINGW64 bash directly without msys2_shell.cmd | |
function mgwbash { | |
param( | |
[Parameter(ValueFromRemainingArguments=$true)] | |
[string[]]$RemainingArgs | |
) | |
$msysArgs = @( | |
'MSYSTEM=MINGW64', 'MSYS2_PATH_TYPE=inherit' , | |
'MSYSCON=' , 'MSYS=winsymlinks:nativestrict', | |
'LOGINSHELL=bash', '/usr/bin/bash' , | |
'--login', '-i' | |
) | |
if ($null -ne ( | |
$msysPath = Get-ChildItem "${env:SystemDrive}\" -Recurse ` | |
-Depth 2 -Filter "msys2_shell.cmd" -EA 0 | | |
foreach { Split-Path $_.FullName -Parent } ) | |
) {} else { throw(New-Object([IO.DirectoryNotFoundException]'')) } | |
if ($RemainingArgs) { $msysArgs += '-c',$RemainingArgs } | |
pushd $msysPath -ErrorAction:Stop # Push-Location | |
.\usr\bin\env.exe @msysArgs | |
popd # Pop-Location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment