This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bash Here - Start Cygwin from a folders context menu


maybe you know "Command Prompt Here"?! It is a convinient tool from
the Powertoys collection to start a Dos shell from the context menu of
any folder (right click on it). The current directory is automatically
set to this folder.

I tried to install something similiar for Cygwin: "Bash Here" should
start a cygwin bash shell from a folders context menu.

The three installation steps, as described at the end of this posting,
works but it is not perfect.

Because some MSDOS routines are involved, the currend directory is
shortened: "c:/Progra~1" instead of "c:/Program Files". This is
cosmetic and has no functional drawback, but looks ugly.  Also, the
window looks like a dos window and does not have that nice cygwin icon
in upper left edge (at least on my Win98SE installation).

Another thing, I am not sure if it always works, is the supposition of
mounted drives: c:, d: etc. On my installation it works great, e.g.
putting a CD into the drive and suddenly e: is available like magic. I
am not sure, if this is the case for all cygwin installations. You
might have to mount all the drives you want to use with BashHere

Here are the steps to Install BashHere (sorry, no skript):

1. Edit Registry

Start regedit.exe.

For Win98 add the following key:

HKEY_CLASSES_ROOT\Directory\shell\BashHere="Bash Here"
/E:4096 /c C:\\cygwin\\cygwin.bat %1"

For WinXP add these:

HKEY_CLASSES_ROOT\Directory\shell\BashHere="Bash Here"
/E:4096 /c C:\\cygwin\\cygwin.bat %1"

Please adjust the path to cygwin.bat if necessary.

Finish regedit.

Now right click on a folder, to open its context menu. You will see
the entry "Bash Here". When you use it, it will start the shell, but
still with your home directory as current ($PWD).

2. Edit cygwin.bat in c:/cygwin

This batch starts the bash shell with the last command line "bash...".
Insert "set BASHHERE=%1" the line before.

This Environment variable now contains the comlete path of the opened
folder and is availabile in the bash shell (echo $BASHHERE).

3. Edit profile 

Make $BASHHERE the current directory by adding the following line to
/etc/profile or ~/.profile:

if [ "$BASHHERE" != "" ]; then
    cd $( echo $BASHHERE | tr "\134" /)

The "tr" replaces \ against /.

That's all, have fun.

Any suggestions or improvements are appreciated! 

regards Martin 

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]