delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/09/23/01:56:05

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
Message-Id: <4.3.2.7.0.20000922172503.00b25100@pop.bresnanlink.net>
X-Sender: cabbey AT pop DOT bresnanlink DOT net
X-Mailer: QUALCOMM Windows Eudora Version 4.3.2
Date: Sat, 23 Sep 2000 00:53:53 -0500
To: luke_bakken AT yahoo DOT com
From: Chris Abbey <cabbey AT bresnanlink DOT net>
Subject: Re: Bash + Shell hack = ?
Cc: cygwin AT sources DOT redhat DOT com
In-Reply-To: <Pine.BSO.4.21.0009220843450.13127-100000@ics-server.interf
ace-net.com>
References: <20000922145540 DOT 16156 DOT qmail AT web114 DOT yahoomail DOT com>
Mime-Version: 1.0

If y'all don't mind I'd like to suggest a slightly cleaner way of doing this.

Starting from the windows explorer end. Windows automatically passes the fully
qualified path to the object as arg 1, so just create an item that points to
cygwin.bat however you wish, mine is called "bash this" and the command to run
is simply "d:\cygwin\cygwin.bat". Windows will automatically call it with the
full path, so if you choose this on c:\yada it would run "d:\cygwin\cygwin.bat
c:\yada".

Now to that we've got it into cygwin.bat we need to propagate it further, using
an environment variable is easiest... here's my cygwin.bat:

@set STARTIN=%1
@d:\cygwin\bin\bash --login -i

the only line there that is important to this is the one setting
the STARTIN envvar, as this is how we pass it on to bash... in order
to act on it I've replaced this line in /etc/profile:

cd $HOME

with this logic:

if [ ! -z "$STARTIN" ]; then
   if [ -d "$STARTIN" ]; then
     cd "$STARTIN"
   else
     echo "$STARTIN is not a valid path."
     cd $HOME
   fi
   unset STARTIN
else
   cd $HOME
fi


which also requires these lines to be changed, as . and ~ may no
longer be the same directory at this point in the script:

test -f ./.profile && . ./.profile
test -f ./.bashrc && . ./.bashrc

becomes:

test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

This gives you a couple other advantages: such as you can create an icon
to open a bash prompt to any given location (I like one in my start bar
that automatically puts me in the root of my products build tree.) and
you can open a new bash window from any dos prompt with 'start cygwin .'

Note that if you want to be able to handle spaces in paths then you can
replace STARTIN's assignment with this:

set STARTIN=%1 %2 %3 %4 %5 %6 %7 %8 %9

which will allow you to have up to 8 spaces in the total path; the downside
to this is that the initial prompt will look a bit odd (trailing spaces)
until you cd the first time.

p.s. any relation to Kirby?


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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