Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MSysGit installs a context menu item that opens a Git Bash prompt at the currently selected folder; however, this opens a cmd.exe window and I would like it to open in Console2 instead.

What modifications do I need to make to get this working?

Note, I have seen this related question, but the answer is outdated - MSysGit is now using a vba script to invoke the bash prompt. Plus it doesn't explicity state how to get things working with Console2.

Update: you may be interested in doing the same with ConEmu, a rather excellent successor to Console. See here: Git Bash Here in ConEmu

share|improve this question
up vote 42 down vote accepted

Here's what I did (your paths with almost certainly vary):

  1. Create a new tab in Console with the following values:
    • Title: Git Bash
    • Icon: C:\Program Files\Git\etc\git.ico
    • Shell "C:\Program Files\Git\bin\sh.exe" --login -i
    • Startup dir: %HOMEDRIVE%%HOMEPATH%
  2. Create a new key in HKEY_CLASSES_ROOT\Directory\shell\ called git_shell2 with a data value of Git Console Here
  3. Create a new key in HKEY_CLASSES_ROOT\Directory\shell\git_shell2\ called command with a data value of "C:\Users\charlesr\My Dropbox\Software\Console2\Console.exe" -t "Git Bash" -d "%1"

This does the trick.

Instead of doing steps 2 and 3 above, you could just copy the following into a .reg file (modify the paths to suit your own config first) then import into the registry.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\git_shell2]
@="Git Console Here"

[HKEY_CLASSES_ROOT\Directory\shell\git_shell2\command]
@="\"C:\\Users\\charlesr\\My Dropbox\\Software\\Console2\\Console.exe\" -t \"Git Bash\" -d \"%1\""
share|improve this answer
    
Just a note for others that find this later, make sure you are using the 32-bit version of Console2 or this will fail. – coderanger Sep 1 '10 at 2:35
    
Note that in the latest msysgit the icon is now in C:\msysgit\share\resources\git.ico – Kevin Berridge Jan 15 '11 at 16:32
1  
Thanks Charles, but why run steps 2 and 3? It works fine just doing step 1, not sure why the need to change the repository settings? – Mark Kadlec Jan 13 '12 at 18:11
2  
Very neat. Note you can also add context menu when clicking in the "background" of a folder (the white part, not on an icon) gist.github.com/4048138 – Ozh Nov 13 '12 at 17:58
    
I've been using this setup for a while, but it seems to have the unfortunate limitation of not being able to execute .bat scripts (without switching to a different tab, running plain Cmd.exe). Has anyone any insights on this? – Eoin Sep 11 '14 at 15:44

The vba script just launches the Git Bash shortcut in the same directory; just change that shortcut to make it point at Console2's executable and configure Console2 so that it uses MSysGit's sh as its shell.


UPDATED

Going into more details as I just needed to do it again on a new computer:

  • Configuring Console2

    1. added a new tab called "git"
    2. set the icon to C:\Program Files (x86)\Git\etc\git.ico
    3. set the shell to C:\Program Files (x86)\Git\bin\sh.exe --login -i
  • Tweaking Git Bash's shortcut

    1. change the shortcut target to C:\Tools\Console2\Console.exe -t git -d . (well where your Console2 binary is located)
    2. enjoy your new "Git Bash Here" launching Console2!

The trick is the "-d ." option passed to Console2: the Git Bash.vbs script changes the current directory to the point pointed by the mouse before launching the shortcut.

Hope that helps.

share|improve this answer

In case anyone stumbles upon this wanting to use MinGW Bash I found a solution for that.

  1. Console2, Edit, Settings, Tabs, Add
  2. Title = Bash
  3. Shell = C:\MinGW\msys\1.0\bin\sh.exe -l
  4. Edit registry

    ni hklm:software/classes/directory/shell/bash/command `
      -f -va 'c:/Console2/Console.exe -t Bash -d %v'
    
  5. Create ~/.profile with the following:

    cd -
    

cd Man Page

This works with 64-bit and 32-bit Console2, not sure what coderanger was on about.

share|improve this answer
    
There are several problems with this command that causes the console to return an error. First, HKCR\...\command should not be enclosed with quotes. Next, I believe by \-d you mean to pass the /d parameter to specify the data for the new registry entry. Also, you need double quotes around the data value and the -t parameter causes Console.exe not to open at all, so exclude that. It should look like this: reg add HKCR\Directory\shell\Bash\command /d "C:\Console2\Console.exe -d \"%V\"" – Dave Kennedy Sep 12 '12 at 21:41
    
It is obvious from your comments that you are still using cmd.exe, as Bash allows use of single and double quotes for strings. You should consider upgrading to Bash. – Steven Penny Sep 12 '12 at 22:06

Assuming you have a Console2 tab named 'bash':

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash]
@="Bash here (Console2)"
"NoWorkingDirectory"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash\command]
@="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -t Bash -d \"%V\"\\"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .