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 know that in explorer you can go to the address bar and type in cmd to open a command prompt for the directory you're currently in. What I'm looking for is a way to do the same thing with cygwin. Inside cygwin I can cd C: to break out of the installation folder and into any drive but I'm looking for a quick way to open cygwin in explorer to the path I'm already at.

I've added C:\cygwin to the Path and can run Cygwin.bat from anywhere (even the address bar of explorer) but it opens up to my cygwin home directory. How can I change that bat to allow what I'm wanting it to do?

share|improve this question
add comment

3 Answers

You could edit your Cygwin.bat, or if you prefer, create a second batch file to go along with it that looks like this...

@echo off

C:
chdir %cd%

C:\cygwin\bin\bash.exe --login -i -c "cd '%cd%' && bash"

Running that from Explorer should give you what you're looking for.

share|improve this answer
    
After removing C: and chdir %cd% this did exactly what I wanted. With those lines, I was getting a bash shell at the C root. I had looked at the -c command but I didn't think about adding && bash to get cygwin to stay open. –  Corey Ogburn Feb 4 '13 at 23:00
add comment

I took the following from http://c2.com/cgi/wiki?BetterCygwinTerminal

//Make sure rxvt is part of your Cygwin install, and update your C:\cygwin\cygwin.bat to this:
@echo off
C:
chdir \cygwin\bin
start rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e /bin/bash --login -i

Since bat files can take parameters, I don't know if you want to pass the current dir in at call time or just have a different one altogether, but the chdir line above is what you want to change. For setting at time of calling (ex. Cygwin.bat C:\code)

@echo off
C:
chdir %1
start rxvt -sr -sl 10000 -fg white -bg black -fn fixedsys -fb fixedsys -tn cygwin -e /bin/bash -login -i

Of course you would need some if else logic on the parameter if you wanted to implement both options, setting a default dir and also have the option of specifying the dir at call time.

share|improve this answer
    
These seem to change cmd's directory before starting rxvt. Once rxvt is started, it's working directory starts in the home directory of my cygwin install. –  Corey Ogburn Feb 4 '13 at 15:52
add comment

Not exactly what you're asking, but very useful is cygwin's chere command, which sets up a context menu for directory windows in explorer, to open a command prompt (or rxvt prompt, or mintty prompt) at that directory level.

share|improve this answer
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.