Last active
December 29, 2015 07:29
-
-
Save originalmind/7635990 to your computer and use it in GitHub Desktop.
Add the PortableGit (supplied by GitHub for Windows) bin directory to your PATH variable and then start your console
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
@rem Usage: set-gitbin-start-console.bat "C:\path\to\my\console.exe" | |
@echo off | |
if "%1" == "" GOTO ErrorPathNotSpecified | |
@rem limit the scope of the changes to environment variables | |
setlocal | |
@rem todo: set GITHUB_ROOT from registry | |
SET GITHUB_ROOT=%USERPROFILE%\AppData\Local\GitHub\ | |
@rem Get the most recently created version of PortableGit | |
FOR /f "delims=" %%F IN ('dir %GITHUB_ROOT%\PortableGit* /O:-D /T:C /B') DO ( | |
set filename=%%F | |
goto SetPath | |
) | |
:SetPath | |
SET GIT_ROOT=%GITHUB_ROOT%%filename% | |
@echo Adding Portable Git location to path: %GIT_ROOT% | |
@if not exist %GIT_ROOT% GOTO ErrorNotFound | |
@set PATH=%GIT_ROOT%\bin;%GIT_ROOT%\cmd;%PATH% | |
GOTO StartShell | |
:ErrorNotFound | |
@echo Sorry can't find git path. | |
@rem We'll start the shell anyway so the user will see this error | |
:StartShell | |
@cmd /k %1 | |
:ErrorPathNotSpecified | |
@echo Please specify the path to your shell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment