Adding cygwin on right click on windows explorer

4

1

I wish to add a command on right click menu in explorer that opens current directory with cygwin.

For same I have successfully added these registries:

[HKEY_CURRENT_USER\software\classes\directory\shell\cygwin]
@="c:\\cygwin\\bin\\bash.exe --login -i -c \"cd '%1'; bash\""

[HKEY_CURRENT_USER\software\classes\drive\shell\cygwin]
@="c:\\cygwin\\bin\\bash.exe --login -i -c \"cd '%1'; bash\""

but this adds the command only when on some folder or drive. I want generic right click on explorer, on which, search gives me this registry to edit:

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin]
@="c:\\cygwin\\bin\\bash.exe --login -i -c \"cd '%1'; bash\""

My problem lies with the value of the key, which doesnt work on %1 but on some static value like /cygdrive/c

Could someone please tell me the proper way to pass current directory to the command, also please refer me some basic and advanced pages for same.

PushpRaj

Posted 2011-03-18T07:39:49.087

Reputation: 149

Answers

5

Better option - No registry edit -- http://perfect-blog-url.blogspot.com/2013/04/open-cygwin-with-right-click-no.html

On Win 7:

  1. Install Cygwin with the 'chere' package.
  2. Right click and Open Cygwin as Administrator.
  3. type "chere -i" or "chere -i -t mintty" if you would like to use Mintty which I personally prefere.

user219318

Posted 2011-03-18T07:39:49.087

Reputation: 69

This worked for me, but I had to install the chere package first, and run it as chere -i -s bash. – Brian Z – 2016-01-28T22:03:51.767

2Please add a bit of summary, the link will break sometime. – vonbrand – 2013-04-23T23:34:21.257

2

I think this is what the chere package does. Instead of tweaking the registry entries yourself, it might be easiest just to install that.

Andrew Schulman

Posted 2011-03-18T07:39:49.087

Reputation: 2 696

1

This is actually better than Cygwin’s chere in my opinion because it only launches once instance of bash.exe. If you look in Task Manager you will notice chere requires 2 instance of bash.exe to work. Not a huge deal but unecessary and annoying.

'directory', 'directory\background', 'drive' |
% {'cmd /c start /d "%v" bash' | ni -f hklm:\software\classes\$_\shell\bash\command}

Source

Steven Penny

Posted 2011-03-18T07:39:49.087

Reputation: 7 294

-1

This is an extension to what @user219318 has posted. If that does not work, you may use this option.

Run the cygwin.bat as 'Run as administrator' and type the following command. You may replace the 'bash' below with your favourite shell, to view the list of shells do cat /etc/shells

chere -i -s bash

Or if you want mintty

chere -i -t mintty -s bash

Zeus

Posted 2011-03-18T07:39:49.087

Reputation: 99

How does this answer the OP's question? – I say Reinstate Monica – 2017-05-11T18:43:09.413