Cygwin instead of cmd open from explorer?

6

1

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?

Corey Ogburn

Posted 2013-02-04T15:25:15.630

Reputation: 551

Answers

1

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.

Costa

Posted 2013-02-04T15:25:15.630

Reputation: 491

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 – 2013-02-04T23:00:16.347

1

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.

Rich Homolka

Posted 2013-02-04T15:25:15.630

Reputation: 27 121

0

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.

MDMoore313

Posted 2013-02-04T15:25:15.630

Reputation: 4 874

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 – 2013-02-04T15:52:34.077