Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Thank you.

share|improve this question

migrated from stackoverflow.com Mar 18 '11 at 20:27

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

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

share|improve this answer
add comment

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.

keys=(
  /root/Directory/Background/shell/Cygwin
  /root/Directory/shell/Cygwin
)
data="cmd /c set CHERE_INVOKING=1 & cd %v & start C:\cygwin\bin\bash -l"
for key in "${keys[@]}"; do
  regtool add "$key"
  regtool add "$key/command"
  regtool set "$key/command/" "$data"
done

.cygwin

share|improve this answer
add comment

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

On Win 7:

  1. Right click and Open Cygwin as Administrator.
  2. type "chere -i" or "chere -i -t mintty" if you would like to use Mintty which I personally prefere.
share|improve this answer
2  
Please add a bit of summary, the link will break sometime. –  vonbrand Apr 23 '13 at 23:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.