Tuesday, September 11, 2012

Add Git Bash Option to Context Menu

I found a nice article, Adding “Open in Git Bash” to the Context Menu, which gives describes the process for adding the Git Bash command to the context menu. I am not a fan of requiring a batch file, we should be able to do it without the batch file.

This is set up for the 32-bit Git install. Here is the command that we can use to not use the batch files.
"cmd.exe /c \"cd \\\"%V\\\" && \"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i\""
If you want to use a different icon, use regedit.exe and navigate to Directory\shell right-click and click "new" and then "expandable string value". Name the new string "Icon" and then set the value to be the location of the icon to use. Export that key and copy the "Icon" entry and past into the appropriate locations below, then delete the "Icon" string that was just created. For a good write-up on this, check out this tutorial http://www.sevenforums.com/tutorials/21878-context-menu-add-shortcuts-icons.html.

Here is my solution:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Directory]

[HKEY_CURRENT_USER\Software\Classes\Directory\Background]

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\bash]
@="Open in Git &Bash"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\bash\command]
@="cmd.exe /c \"cd \"%V\" && \"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i\""
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,00,5c,00,\
  47,00,69,00,74,00,5c,00,65,00,74,00,63,00,5c,00,67,00,69,00,74,00,2e,00,69,\
  00,63,00,6f,00,00,00

[HKEY_CURRENT_USER\Software\Classes\Directory\shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\bash]
@="Open in Git &Bash"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\bash\command]
@="cmd.exe /c \"cd \"%V\" && \"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i\""
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,00,5c,00,\
  47,00,69,00,74,00,5c,00,65,00,74,00,63,00,5c,00,67,00,69,00,74,00,2e,00,69,\
  00,63,00,6f,00,00,00
I have not figured out how to set the icon on the CMD window to the git icon instead of the basic CMD icon. It is not that important, it works without it. Perhaps one day.

No comments: