Sunday, March 20, 2011

Pinning PortableGit to the Windows 7 taskbar

Microsoft, in all its sagacity, decided that you couldn't pin batch files to the Windows 7 taskbar - something that people have been doing for ages, and have come to like.

Googling for the problem showed three main approaches:

  • Converting batch files to exe - bad
  • Putting all batch files in a folder and making a toolbar out of the folder - less bad but still yucky
  • Tricking W7 into thinking its an exe by opening up the hidden folder that contains the taskbar (Win-R, "Shell:user pinned" will get you there), and adding the shortcut manually. This didnt work except for briefly adding said shortcut to the taskbar, which disappeared soon.
Since all I needed was to have a one-click access to Portable Git, I thought maybe the executable could be called directly, so I ran git-bash.exe to test it out. pwd and exit would work, but not even ls. 

So then I looked at what git-bash.bat did extra. Turns out all it does essentially is to add some params to the call to the executable. So here then, is the solution:
  • Select %PortableGitHome%\bin\bash.exe, and drag it to the taskbar
  • Rt click to show the pin menu, and rt click again on bash to reveal the properties window.
  • Change the Target to "%PortableGitHome%\bin\bash.exe --login -i"
  • For bonus points, change the icon to a Git-specific one. You could use the one from GitGUI, or a free alternative one
Note: %PortableGitHome% is not a real variable, replace with your install dir.

No comments: