delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/06/20/01:05:43

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Tue, 19 Jun 2001 20:41:48 +0100 (BST)
From: david lars clayton <claytodl AT sbu DOT ac DOT uk>
Message-Id: <200106191941.UAA0000011259@CSDAlpha1.sbu.ac.uk>
To: cygwin AT cygwin DOT com
Subject: Bash Prompt Here utility idea...

In my opinion, the most useful powertoy/Win 98 addon is the "DOS Prompt Here"
toy.  For those of you who don't know what this does, it allows you to call up
a command prompt at a directory selected by the mouse by selecting "DOS Prompt
Here" from the right mouse button menu.

So, one dark Sunday evening (well, it was more like Monday morning by that time)
I thought to myself, "wouldn't it be cool to have a Bash Prompt Here tool?"  So 
here it is, folks.  Here's a guide to setting up your cygwin to do everything th
at the DOS Prompt Here lets you do, but with Bash.

Step 1 - Init Scripts
---------------------
We want to preserve the initial environment, but to stop /etc/profile from
cd'ing to the $HOME directory _only_ when we use the Bash Prompt tool.  It must
behave normally when we start the program any other way.  This means that we 
can't use "bash --login" and that adding a command with -c would make things a
little difficult, but it also means that we can't change /etc/profile too much.

I created a file called /etc/profile.bash_here which would be called as the main
rcfile when we start bash.  In this, I have two commands:

export BASH_HERE=1
. /etc/profile

Rather than create a whole new profile script from scratch (or a duplicate of
/etc/profile) which may have caused problems later on, I simply modified the
/etc/profile script so that the line which reads:

cd "$HOME"

is changed to:

if [ ! $BASH_HERE ]; then
  cd "$HOME"
fi

Should be fairly self explanatory (look at the manpage for test if it isn't).


Step 2 - Batch File
-------------------
The batch file will be called every time you do the right click and select
"Bash Prompt Here".  Here's what it should look like...

REM -- Start of batch file --

@echo off
cd %1
c:\cygwin\bash -c "/bin/bash --rcfile /etc/profile.bash_here"

REM -- End of batch file


Step 3 - The Registry
---------------------
Next we modify the registry.  Fire up Regedit, and create a new key under
HKEY_CLASSES_ROOT.Directory.Shell and call it BashHere.  Select this new key,
and change the value of "(Default)" to "&Bash Prompt Here" by double clicking
on it. Next, create a new key under your newly created BashHere key, and call it
"Command".  Again, select the new "Command" key, and change the value of 
"(Default)" to the following:

C:\WINDOWS\COMMAND.COM /E:4096 /c C:\cygwin\bashhere.bat %1

And that's it!  Simple, huh?

Dave Clayton
andpigswillfly AT mail DOT com

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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