I enjoy using the bash command prompt that comes with msysgit. Every once in a while I find myself having to launch the Visual Studio 2008 Command Prompt – usually to initiate a build without having to open a solution up in Visual Studio. This is annoying when I already have a bash window open in the desired folder. In the spirit of automating things I do often, I’ve written a batch file that calls out to Visual Studio’s command-line environment setup script before launching git bash. This ensures the correct PATH is set along with other required environment variables. Here’s how I’ve set things up:
- Create the wrapper batch file
Save the following script as git_bash_vs.bat. Remember to modify the Visual Studio and msysgit paths in the script.
@call %myVsDir%\vcvarsall.bat x86
@"E:\development\git\bin\sh.exe" --login -i
- Modify the Git Bash start menu shortcut
Edit the Git Bash shortcut by right clicking on it and selecting Properties. Now, update the Target to point at your git_bash_vs.bat script, and set the Start In directory to be wherever you wish. (I usually set this to my project directory where all of my source code is stored.)
If you also happen to have External Tool entries in Visual Studio that launch git bash, don’t forget to update them too!