Last active
January 25, 2017 18:27
-
-
Save Pendrokar/a7fc59791d4eb113ea0f4670274f18b6 to your computer and use it in GitHub Desktop.
Access Git in command prompt from within 'Bash on Ubuntu on Windows' environment by having this within environment variables. I am not a good Batch script writer though.
This file contains 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
@echo off | |
SETLOCAL EnableDelayedExpansion | |
rem Get drive letter along with the colon and backslash | |
SET _cdDrive=%cd:~0,3% | |
rem Get drive letter | |
SET mntPath=%_cdDrive:~0,1% | |
rem mnt/<driveLetter> is lower case, has to be converted | |
call :LoCase mntPath | |
SET mntPath=/mnt/%mntPath%/ | |
rem Get all received arguments | |
SET fullWinArguments=%* | |
rem Replace <WindowsDrive>:\ | |
SET fullLinuxArguments=!fullWinArguments:%_cdDrive%=%mntPath%! | |
rem Replace backslahes with Linux forward-slashes | |
SET fullLinuxArguments=!fullLinuxArguments:\=/! | |
bash -c 'git %fullLinuxArguments%' | |
GOTO:EOF | |
:LoCase | |
:: Subroutine to convert a variable VALUE to all lower case. | |
:: The argument for this subroutine is the variable NAME. | |
SET %~1=!%1:A=a! | |
SET %~1=!%1:B=b! | |
SET %~1=!%1:C=c! | |
SET %~1=!%1:D=d! | |
SET %~1=!%1:E=e! | |
SET %~1=!%1:F=f! | |
SET %~1=!%1:G=g! | |
SET %~1=!%1:H=h! | |
SET %~1=!%1:I=i! | |
SET %~1=!%1:J=j! | |
SET %~1=!%1:K=k! | |
SET %~1=!%1:L=l! | |
SET %~1=!%1:M=m! | |
SET %~1=!%1:N=n! | |
SET %~1=!%1:O=o! | |
SET %~1=!%1:P=p! | |
SET %~1=!%1:Q=q! | |
SET %~1=!%1:R=r! | |
SET %~1=!%1:S=s! | |
SET %~1=!%1:T=t! | |
SET %~1=!%1:U=u! | |
SET %~1=!%1:V=v! | |
SET %~1=!%1:W=w! | |
SET %~1=!%1:X=x! | |
SET %~1=!%1:Y=y! | |
SET %~1=!%1:Z=z! | |
GOTO:EOF |
Updated Batch file so that it converts drive letter to /mnt/[DriveLetter]. Example:
C:\Users\Yanis Lukes\Documents\My Games\GalCiv3\Mods\StarControl>git status "C:\Users\Yanis Lukes\Documents\My Games\GalCiv3\Mods\StarControl\Game"
=>git status "/mnt/c/Users/Yanis Lukes/Documents/My Games/GalCiv3/Mods/StarControl/Game"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Command prompt even displays color coding.