delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/27/16:11:38

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: Martin Gramatke <xmit AT gmx DOT de>
To: cygwin AT cygwin DOT com
Subject: Bash Here - Start Cygwin from a folders context menu
Date: Mon, 27 May 2002 22:10:47 +0200
Reply-To: xmit AT gmx DOT de
Message-ID: <1215fu09ddkm1nclouq65bh8g672um24he@4ax.com>
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g4RKBbJ20974

Hi,

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
manually.

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"
HKEY_CLASSES_ROOT\Directory\shell\BashHere\command="C:\\WINDOWS\\COMMAND.COM
/E:4096 /c C:\\cygwin\\cygwin.bat %1"

For WinXP add these:

HKEY_CLASSES_ROOT\Directory\shell\BashHere="Bash Here"
HKEY_CLASSES_ROOT\Directory\shell\BashHere\command="C:\\WINDOWS\\System32\\COMMAND.COM
/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" /)
fi

The "tr" replaces \ against /.

That's all, have fun.

Any suggestions or improvements are appreciated! 

regards Martin 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019