Created
July 12, 2017 08:27
git batch file for using with Bash on Ubuntu on Windows
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
@echo off | |
SETLOCAL enableextensions enabledelayedexpansion | |
:: Thanks: | |
:: - https://stackoverflow.com/questions/37000166/getting-pycharm-to-recognize-python-on-the-windows-linux-subsystem-bash-on-wind | |
:: ################################################################################### | |
:: Set up the current directory, so that we can change into it before calling git | |
:: ################################################################################### | |
:: Extract the drive letter | |
SET "DIR=%cd%" | |
:: Convert drive letter to lower case and add /mnt/ | |
FOR %%i IN ("A:\=/mnt/a/" "B:\=/mnt/b/" "C:\=/mnt/c/" "D:\=/mnt/d/" "E:\=/mnt/e/" "F:\=/mnt/f/" "G:\=/mnt/g/" "H:\=/mnt/h/" "I:\=/mnt/i/" "J:\=/mnt/j/" "K:\=/mnt/k/" "L:\=/mnt/l/" "M:\=/mnt/m/" "N:\=/mnt/n/" "O:\=/mnt/o/" "P:\=/mnt/p/" "Q:\=/mnt/q/" "R:\=/mnt/r/" "S:\=/mnt/s/" "T:\=/mnt/t/" "U:\=/mnt/u/" "V:\=/mnt/v/" "W:\=/mnt/w/" "X:\=/mnt/x/" "Y:\=/mnt/y/" "Z:\=/mnt/z/") DO CALL SET "DIR=%%DIR:%%~i%%" | |
:: Change backslash to forward slash. Must run after converting the drive letter. | |
SET "DIR=%DIR:\=/%" | |
:: ################################################################################### | |
:: Fix the arguments | |
:: ################################################################################### | |
SET ARGS=%* | |
:: Convert drive letter to lower case and add /mnt/ | |
FOR %%i IN ("A:\=/mnt/a/" "B:\=/mnt/b/" "C:\=/mnt/c/" "D:\=/mnt/d/" "E:\=/mnt/e/" "F:\=/mnt/f/" "G:\=/mnt/g/" "H:\=/mnt/h/" "I:\=/mnt/i/" "J:\=/mnt/j/" "K:\=/mnt/k/" "L:\=/mnt/l/" "M:\=/mnt/m/" "N:\=/mnt/n/" "O:\=/mnt/o/" "P:\=/mnt/p/" "Q:\=/mnt/q/" "R:\=/mnt/r/" "S:\=/mnt/s/" "T:\=/mnt/t/" "U:\=/mnt/u/" "V:\=/mnt/v/" "W:\=/mnt/w/" "X:\=/mnt/x/" "Y:\=/mnt/y/" "Z:\=/mnt/z/") DO CALL SET "ARGS=%%ARGS:%%~i%%" | |
:: Backslash to forward slash | |
SET ARGS=!ARGS:\=/! | |
:: ################################################################################### | |
:: Execute it!!! | |
:: ################################################################################### | |
If %PROCESSOR_ARCHITECTURE% == x86 ( | |
C:\Windows\sysnative\bash.exe --login -c '. ~/start_keepass_agent.sh; cd "%DIR%"; git %ARGS%' | |
) Else ( | |
bash.exe --login -c '. ~/start_keepass_agent.sh; cd "%DIR%"; git %ARGS%' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment