delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/30/15:00:58

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
X-Server-Uuid: 28431ec2-fd89-11d2-a089-00a0c9f498e6
Message-ID: <0DB4E7930F5CD411AC93009027EE744C09345B74@ddcexch.ddcnet.detroitdiesel.com>
From: "Kilroy, David" <david DOT kilroy AT detroitdiesel DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: RE: Bash Here - Start Cygwin from a folders context menu
Date: Thu, 30 May 2002 14:59:45 -0400
MIME-Version: 1.0
X-WSS-ID: 10E8AA26324658-01-01
Note-from-DJ: This may be spam

------_=_NextPart_000_01C2080C.29FAFEA0
Content-Type: text/plain; 
 charset=iso-8859-1
Content-Transfer-Encoding: 7bit


From the recent discussion, I thought it a little silly that all the
different incantations only worked for a particular shell/window combo.
After a read of some older mailing list stuff discussing different ways of
doing things I came up with a few modifications to the files Gerrit posted
[diffs attached]

It allows you to do any of:
./install bash
./install rxvt
./install [batch]

And goes off and sets up your registry (and start up files in the case of
batch) to do things in your preferred method.

It is relatively easy to add command line incantations for other shells so
that they can be provided for as well.

Also:
1) Tries to leverage any existing cygwin.bat to create cygwin_indir.bat, if
thats what you want.
2) Stops repeated additions to ~/.bashrc for repeated installs
3) handles missing ~/.bashrc
4) Uses bare bones rxvt startup line so the users .Xdefaults are used

Gerrit, would you be interested in adding these changes (or similar) to the
file you're already hosting? The FAQ can then deal with "but I want Cygwin
Prompt Here to start ?sh, not bash" [assuming appropriate incantations are
added].


Dave.

Old thread reference:
http://sources.redhat.com/ml/cygwin/2002-04/msg00647.html


> From: Gerrit P. Haase [mailto:freeweb AT nyckelpiga DOT de]
> Subject: Re: Bash Here - Start Cygwin from a folders context menu
> 
> Fetch the original from Glen Coakley:
> http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html
> 
> AND please fetch the diff here:
> http://koeln.convey.de/cywgin/CygwinPromptHere/
> 
> Or fetch the ready patched package at my site.
>
http://koeln.convey.de/cywgin/CygwinPromptHere/CygwinPromptHere-20020528.tar
.gz


------_=_NextPart_000_01C2080C.29FAFEA0
Content-Type: application/octet-stream; 
 name=cphinf.diff
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; 
 filename=cphinf.diff

--- CygwinPromptHere.inf.tpl.orig	2002-05-28 10:02:06.000000000 =
-0400=0A=
+++ CygwinPromptHere.inf.tpl	2002-05-30 12:54:40.000000000 -0400=0A=
@@ -63,5 +63,7 @@=0A=
 CygwinPromptHereName=3D"Cygwin Prompt Here PowerToy"=0A=
 CygwinPromptHereAccel=3D"Cy&gwin Prompt Here PowerToy"=0A=
 =
UDHERE=3D"Software\Microsoft\Windows\CurrentVersion\Uninstall\CygwinProm=
ptHere"=0A=
+BATCH_SHELL_CMD=3D"cygwin_indir.bat ""%1"""=0A=
+CMD_BASH_SHELL_CMD=3D"bin\bash.exe --login -c ""cd '%1'; exec =
bash"""=0A=
+RXVT_BASH_SHELL_CMD=3D"bin\rxvt.exe -e /bin/bash.exe --login -c ""cd =
'%1'; exec bash"""=0A=
 CYGWIN_ROOT=3D=0A=
-CYGWIN_SHELL_CMD=3D"cygwin_indir.bat ""%1"""=0A=

------_=_NextPart_000_01C2080C.29FAFEA0
Content-Type: application/octet-stream; 
 name=install.diff
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; 
 filename=install.diff

--- install.orig	2002-05-28 10:02:06.000000000 -0400=0A=
+++ install	2002-05-30 13:45:17.000000000 -0400=0A=
@@ -11,13 +11,27 @@=0A=
 =0A=
 This 'install' will adapt to the version of Windows that you are using =
and=0A=
 locate your cygwin root directory. It will modify the registry entries =
for=0A=
-Drives and Directories under HKEY_CLASSES_ROOT, add a cygwin_indir.bat =
file in=0A=
+Drives and Directories under HKEY_CLASSES_ROOT. =0A=
+=0A=
+The following are valid options:=0A=
+    bash - start bash from the default command shell=0A=
+    rxvt - start bash under rxvt=0A=
+    batch - run a batch file based on the current /cygwin.bat =
(default)=0A=
+=0A=
+Under batch, I will add a cygwin_indir.bat file in=0A=
 your cygwin root directory and append a few lines to your .bashrc. =0A=
 =0A=
 The changes to your .bashrc will only be executed if you are running =
under=0A=
-cygwin (I share my .bashrc with my Unix box.) =0A=
+cygwin (I share my .bashrc with my Unix box.) Also these changes will =
not =0A=
+be run under other user profiles.=0A=
+=0A=
+The advantage of using the options bash or rxvt is that no temporary =
files are=0A=
+used, and the extra command invocation in memory is spared. The rxvt =
command=0A=
+used is a bare bones 'rxvt -e bash', so your preferences should go =
into=0A=
+~/.Xdefaults=0A=
 =0A=
 EOF=0A=
+# Add an odd apostrophe to stop the 'comment' leaking when viewing in =
xemacs'=0A=
 =0A=
 #################### Are you sure you want to do this? =
####################=0A=
 PROMPT=3D"Would you like to continue? [y/n]"=0A=
@@ -35,14 +49,36 @@=0A=
 fi=0A=
 echo ""=0A=
 =0A=
-CYGWIN_ROOT_DOS=3D`regtool get 'HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus =
Solutions\Cygwin\mounts v2\/\native'`=0A=
-CYGWIN_ROOT_CYGWIN=3D`cygpath -u $CYGWIN_ROOT_DOS`=0A=
-CYGWIN_ROOT_DOS=3D`cygpath -w $CYGWIN_ROOT_DOS`=0A=
+CYGWIN_ROOT_CYGWIN=3D/=0A=
+CYGWIN_ROOT_DOS=3D`cygpath -w $CYGWIN_ROOT_CYGWIN`=0A=
 =0A=
-#################### Make necessary additions to .bashrc =
####################=0A=
+case $1 in=0A=
+batch)=0A=
+    DESIRED_SHELL=3D%BATCH_SHELL_CMD%=0A=
+;;=0A=
+cmd-bash | bash)=0A=
+    DESIRED_SHELL=3D%CMD_BASH_SHELL_CMD%=0A=
+;;=0A=
+rxvt-bash | rxvt)=0A=
+    DESIRED_SHELL=3D%RXVT_BASH_SHELL_CMD%=0A=
+;;=0A=
+# Add you preferred windowing/shell combo here=0A=
+# and then add appropriate start up line to .inf.tpl=0A=
+*)=0A=
+    DESIRED_SHELL=3D%BATCH_SHELL_CMD%=0A=
+;;=0A=
+esac=0A=
+=0A=
+# Only modify/create ./bashrc and cygwin_indir.bat if running from a =
batch file=0A=
+# otherwise things are handled in the registry and this isn't =
required=0A=
+if [ "$DESIRED_SHELL" =3D "%BATCH_SHELL_CMD%" ]=0A=
+then=0A=
 =0A=
-if [ `grep -c BPH_TEMP_FILE $HOME/.bashrc` =3D 0 ]; then=0A=
-  cat <<EOF >> $HOME/.bashrc=0A=
+#################### Make necessary additions to .bashrc =
####################=0A=
+# create it if necesary=0A=
+  touch $HOME/.bashrc=0A=
+  if [ `grep -c /tmp/bphdir.tmp $HOME/.bashrc` =3D 0 ]; then=0A=
+    cat <<EOF >> $HOME/.bashrc=0A=
 =0A=
 # Additions for "Cygwin Prompt Here" functionality=0A=
 if [ -r /tmp/bphdir.tmp ]; then=0A=
@@ -52,38 +88,36 @@=0A=
 # End of: Additions for "Cygwin Prompt Here" functionality=0A=
 =0A=
 EOF=0A=
-fi=0A=
-=0A=
-#################### Create and install the .inf file =
####################=0A=
-# sed/shell quoting -- Ugh!=0A=
-CYGWIN_ROOT_DOS_ESCAPED=3D`echo "$CYGWIN_ROOT_DOS" | sed -e =
's;\\\\;\\\\\\\\;g'`=0A=
-sed -e "s;\(CYGWIN_ROOT=3D\);\\1\"$CYGWIN_ROOT_DOS_ESCAPED\";g" \=0A=
-	< CygwinPromptHere.inf.tpl > CygwinPromptHere.inf=0A=
-=0A=
-CYG_COMSPEC=3D`cygpath -u $COMSPEC`=0A=
-INSTALL_CMD=3D`regtool get =
'HKEY_CLASSES_ROOT\inffile\shell\Install\command\' \=0A=
-	    | sed -e 's; %1;;g'`=0A=
-DOS_PWD=3D`cygpath -w -a "$PWD"`=0A=
-=0A=
-# Windows (2000) looks for the exact filename specified in the .inf =
file.=0A=
-$CYG_COMSPEC /c start $INSTALL_CMD $DOS_PWD\\CygwinPromptHere.inf=0A=
+  fi=0A=
 =0A=
 #################### Create cygwin_indir.bat ####################=0A=
 =0A=
 # old CYGWIN_DRIVE=3D`echo $CYGWIN_ROOT_DOS | cut -d'\\' -f1`=0A=
-CYGWIN_DRIVE=3D`echo $CYGWIN_ROOT_DOS | cut -d: -f1`:=0A=
-CYGWIN_DIR=3D`echo $CYGWIN_ROOT_DOS | cut -d: -f2`=0A=
+  CYGWIN_DRIVE=3D`echo $CYGWIN_ROOT_DOS | cut -d: -f1`:=0A=
+  CYGWIN_DIR=3D`echo $CYGWIN_ROOT_DOS | cut -d: -f2`=0A=
 =0A=
 # Backup old file=0A=
-if [ -r /cygwin_indir.bat ]=0A=
-then=0A=
+  if [ -r /cygwin_indir.bat ]=0A=
+  then=0A=
     TODAY=3D`date +'%Y%m%d'`=0A=
     cp /cygwin_indir.bat /cygwin_indir.${TODAY}.bat=0A=
     echo "A copy of the existing file '/cygwin_indir.bat' has been =
saved as:"=0A=
     echo "/cygwin_indir.${TODAY}.bat."=0A=
-fi=0A=
+  fi=0A=
 =0A=
-cat <<EOF > /cygwin_indir.bat=0A=
+# if the standard cygwin.bat exists, pass it through sed to get =
cygwin_indir.bat=0A=
+# so we retain the users options/preferences. Try and cygpath after =
cding to /bin=0A=
+# else create it=0A=
+  if [ -x /cygwin.bat ]=0A=
+  then=0A=
+    cat <<EOF > batch.sed=0A=
+/\(\(cd\|chdir\).*bin\)[[:space:]]*$/I a\\=0A=
+cygpath -u %1> ..\\\\tmp\\\\bphdir.tmp=0A=
+EOF=0A=
+    sed -f batch.sed /cygwin.bat > /cygwin_indir.bat=0A=
+    rm batch.sed=0A=
+  else=0A=
+    cat <<EOF > /cygwin_indir.bat=0A=
 @echo off=0A=
 title Cygwin Bash Shell=0A=
 =0A=
@@ -91,12 +125,28 @@=0A=
 cd $CYGWIN_DIR\bin=0A=
 cygpath -u %1> $CYGWIN_ROOT_DOS\tmp\bphdir.tmp=0A=
 =0A=
-rxvt -sr -sl 2500 -fg lightblue -geometry 90x30 -bg midnightblue -sb =
-tn rxvt  -fn "Lucida Console-14" -e /usr/bin/bash --login -i=0A=
+bash --login -i=0A=
 =0A=
 exit=0A=
 EOF=0A=
+  fi=0A=
+  chmod a+x /cygwin_indir.bat=0A=
+fi=0A=
+=0A=
+#################### Create and install the .inf file =
####################=0A=
+# sed/shell quoting -- Ugh!=0A=
+CYGWIN_ROOT_DOS_ESCAPED=3D`echo "$CYGWIN_ROOT_DOS" | sed -e =
's;\\\\;\\\\\\\\;g'`=0A=
+sed -e "s;\(CYGWIN_ROOT=3D\);\\1\"$CYGWIN_ROOT_DOS_ESCAPED\";g" -e =
"s;%CYGWIN_SHELL_CMD%;$DESIRED_SHELL;g" \=0A=
+	< CygwinPromptHere.inf.tpl > CygwinPromptHere.inf=0A=
+=0A=
+CYG_COMSPEC=3D`cygpath -u $COMSPEC`=0A=
+INSTALL_CMD=3D`regtool get =
'HKEY_CLASSES_ROOT\inffile\shell\Install\command\' \=0A=
+	    | sed -e 's; %1;;g'`=0A=
+DOS_PWD=3D`cygpath -w -a "$PWD"`=0A=
+=0A=
+# Windows (2000) looks for the exact filename specified in the .inf =
file.=0A=
+$CYG_COMSPEC /c start $INSTALL_CMD $DOS_PWD\\CygwinPromptHere.inf=0A=
 =0A=
-chmod a+x /cygwin_indir.bat=0A=
 =0A=
 #################### Installation Complete ####################=0A=
 =0A=


------_=_NextPart_000_01C2080C.29FAFEA0
Content-Type: text/plain; charset=us-ascii

--
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/
------_=_NextPart_000_01C2080C.29FAFEA0--

- Raw text -


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