Tuesday, January 22, 2013

msysGit Context Menu Missing Issue Fix

This is a short fix for msysGit's context menus.

Something that's bothered me about the way msysGit context menus work is that they only work when you actually have a directory selected. You can't just click on the Windows Explorer "background" and launch the bash at that location.

The issue was brought up to the msysGit team but they didn't actually make any changes to fix the issue. Whether they haven't done it yet, don't know how, or intend this to be the correct behavior, I don't know. I just know it's not how I want it to be.

I could fix this by using the git-cheetah dll, but I don't really like this because it creates tons of menus I don't really want. It really doesn't fit into the way I use Git.

I use TortoiseGit for simple day-to-day use and the Git Bash when I need to do some heavy lifting. The less items I can have cluttering my already large explorer context menu the better.

The first step is to isolate the existing context menu registry keys. Start up regedit and find HKEY_CLASSES_ROOT\Directory\shell\. There should be 2 keys there for the git_gui and git_shell. Export these out and open them up in a text editor.

There are 2 things we need to change. First we need to modify the location of the registry keys to HKEY_CLASSES_ROOT\Directory\Background\shell\. The second change is to replace the %1 with %V. For example, here's how my exported .reg files looked after I made the changes:

Git GUI

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui]
@="Git &GUI Here"

[HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui\command]
@="\"C:\\Programs\\Git\\bin\\wish.exe\" \"C:\\Programs\\Git\\libexec\\git-core\\git-gui\" \"--working-dir\" \"%V\""

Git Shell

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\background\shell\git_shell]
@="Git Ba&sh Here"

[HKEY_CLASSES_ROOT\Directory\background\shell\git_shell\command]
@="\"C:\\Windows\\SysWOW64\\wscript\" \"C:\\Programs\\Git\\Git Bash.vbs\" \"%V\""

Re-import these into regedit and we're done! We now have the ability to start the Git Bash or Git GUI by right clicking on an empty spot in the Windows Explorer.

No comments :

Post a Comment