Git Bash & Console2, Finally!Posted: December 22, 2012
I have seen this information in various places and in various pieces and finally have taken the time and effort to put it together and implement a working solution on my work machine. First a bit of context for the situation and my motivations.
My work machine is pretty much my only machine. I have an older personal laptop that I do not use much anymore. It is a ThinkPad R50 that was manufactured in Apr. 2002, with a Centrino 1.0 ghz processor and an upgraded 2gb of RAM. It dual boots Windows XP and Ubuntu 12, and doesn’t do much more. I have Visual Studio 2010 on it and up until this time last year it was my only machine and I still worked on it about 30-35 hours per week. In all honesty I can say that it is the best laptop I have ever owned (not used) and by best I do not mean the most powerful, but just the best overall. It is a horse, I bought it used from my best friend for something like $150, but I don’t really remember. He had had it for a few years and put the extra memory in it. I have used it steadily as my only personal machine ever since and it has served me well. Okay, enough about my old laptop, as it is just that, my old laptop.
These days I am using my work machine as both my work machine and my personal machine. To qualify that however, I need to say that I do not spend an inordinate amount of time in front of it outside of work. I do use it to keep my iTunes library and sync my iPhone 4s, on which I listen to many audio books and watch many cartoon episodes. I also use it to download media and some light research. Otherwise it is work-related, to the tune of an average of 40-45 hours per week, with the 40 being billed to work. On that topic, I have been using RescueTime at the behest of Scott Hanselman, whose writing on productivity and what being a developer feels like I cannot recommend enough. So, due to RescueTime, I know a little more about how much I use my computer and what I do on it, it is really cool. Nice little summary at the end of each week, certainly helps me feel a little less guilty and a little more like I should about myself, I really do work hard.
But, I digress. My new machine (well I have had it about 11 months and it was new when I got it) is a Dell Precision and much more of a beefcake than the thinkpad. Here are the specs, just cause I like Speccy and enjoy an excuse to use it.
Git Bash and Console2, so what about ’em…
At work we use a product called Surround SCM (and its companion defect suite, Test Track Pro) by Seapine Software. These two products track all our work including feature requests, action items and defects, and the source itself. The products work in tandem with each other and are an integral part of our SDLC. I cannot check in any source code with out an attached item in TTP. Unfortunately, Surround uses the centralized version control system that uses the check out -> edit -> check in workflow just like visual source safe did. Where as Git, is a distributed version control system that uses a pull changes -> work -> push changes model that is much more conducive to multiple developers and branching/merging.
I use Git locally on my laptop to track changes while I am working on various tasks. Git allows me to keep track of larger features and tasks that might take me days to complete. I can do smaller, incremental commits and use branching to go on tangents and to handle some smaller fix that has to take priority. All the while I keep my master branch in sync with the centralized Surround repository. I do not push to any remote repository with Git, I simply use it to track my Source directory on my local machine. It could be called local revision control for my working copy of the code. That might sound complicated and like too much work that is unnecessary but I find that it is working well for me so far (it hasn’t been that long).
Enter another tool, one that I have used for a long time, several years at least, not exactly sure. And that is a command prompt replacement for windows called Console2 that provides a tabbed command console interface with improved usability over the clunky default Windows command prompt. I use one other console application lately that is a MinGW32 instance that is a bash shell installed with the Git for Windows package. Now we come to the issue, and I apologize for how long it took to get here. Console2’s tabbed interface is nice and open on my desktop most of the day but I have to use the Git Bash shortcut to open the shell for working with Git. So I went out a few months ago and did some Googlin’ and got some instructions for setting up a Git tab withing my Console2, but it never worked right. it would open up but would not initialize and show the prompt. So after spending a little bit of time fooling with it I gave up and just used two separate command windows, one for Git and one for everything else (I also have a VS Command Prompt tab that works great and saves me finding the shortcut when I need it).
That is, until today. I had a very interesting day that led me down several research paths solving problems most of the day, I have actually been working, except for meal breaks, since 7am this morning (I looked at the system clock and see that it is 12:04am, haven’t done this in a while). I now have a working Git Bash prompt in a Console2 tab. Alongside my VS Command Prompt tab and my Cygwin shell tab. And, oddly, I have sat here for the last 45 minutes copying unrelated links and including way too much detail in this post just so that I could share the solution with… well, probably no one. But maybe someone, even a few people. I am going to include screenshots and form field values for several things, as well as links to where I found the information and that should get anyone there.
The Git for Windows package is installed in the C:\Program Files (x86)\Git directory. Here are the settings for the Console2 tab for the Git Bash prompt:
Title: Git Bash
Icon: C:\Program Files (x86)\Git\etc\git.ico
Shell: C:\Program Files (x86)\Git\bin\sh.exe –login -i
Startup Dir: %HOMEDRIVE%%HOMEPATH%
To the left here is the settings dialog with the above values in place where they go in the form. These values work for me with the install directory in the previous paragraph. It doesn’t matter where you have Console2 installed (it is standalone anyways), at least not at this point.
Next I will show you how I have setup a shortcut on my desktop that will open an instance of the Console with the Git Bash tab initialized rather than the default tab, which is just the regular command prompt.
The desktop shortcut does, of course depend on where you have installed the Console2 directory. I have mine installed, surprisingly enough, in the C:\Program Files (x86)\Console2 directory. Which results in the following values for the shortcut, created blank by right-clicking on the desktop and selecting New -> Shortcut.
You need the extra set of quotes around the target value as it has separate quoted values that must be grouped with the outer quotes. Without these extra outer quotes I was getting an error message saying that the Target value was invalid when I tried to save the shortcut.
Target: “”C:\Program Files (x86)\Console2\Console.exe” -t “Git Bash””
Start In: %HOMEDRIVE%%HOMEPATH%
Finally I will include the link where I finally found some accurate information. My settings are different as I use some different values of course, as you well may depending on your system. There is also another tidbit here that I have used to create a right-click shortcut, but only the one for right-clicking on a file and being offered a choice to open “Git Bash Here.” I am not entirely sure how much I will use this one, but I went ahead and added it anyways. Just opened Regedit and followed the instructions.
So, there it is, after too much ado. Cheers!