Last active
August 29, 2015 14:17
-
-
Save justsh/7c7f439725b126eebddf to your computer and use it in GitHub Desktop.
Modified `Git Bash.vbs` script from Git for Windows to support ansicon and a default working directory. Batch file can be pinned to taskbar with alt. icon. Running from VBScript is gross, but ensures an up to date environment without killing explorer or logging in/out
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
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set shell = CreateObject("WScript.Shell") | |
' Lookup System and User environment variables defined in the current process | |
Set env = shell.Environment("PROCESS") | |
Const TemporaryFolder = 2 | |
linkfile = fso.BuildPath(fso.GetSpecialFolder(TemporaryFolder), "Git Bash.lnk") | |
gitdir = fso.GetParentFolderName(WScript.ScriptFullName) | |
ansicon = fso.BuildPath(env("ANSICON64"), "ansicon.exe") | |
' Dynamically create a shortcut with the current directory as the working directory. | |
Set link = shell.CreateShortcut(linkfile) | |
if ansicon <> "" then | |
link.TargetPath = ansicon | |
link.Arguments = fso.BuildPath(gitdir, "bin\bash.exe") + " --login -i" | |
else | |
link.TargetPath = fso.BuildPath(gitdir, "bin\bash.exe") | |
link.Arguments = "--login -i" | |
end if | |
link.IconLocation = fso.BuildPath(gitdir, "etc\git.ico") | |
if WScript.Arguments.Length > 0 then | |
link.WorkingDirectory = WScript.Arguments(0) | |
else | |
link.WorkingDirectory = env("HOME") | |
end if | |
link.Save | |
Set app = CreateObject("Shell.Application") | |
app.ShellExecute linkfile |
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
@wscript.exe "%GIT_FOR_WINDOWS%\Git Bash.vbs" %* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment