public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Bash Here - Start Cygwin from a folders context menu
@ 2002-05-28 10:57 Thomas Schweikle
  2002-05-29 11:20 ` Peter A. Castro
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Schweikle @ 2002-05-28 10:57 UTC (permalink / raw)
  To: Gerrit P. Haase; +Cc: cygwin

Hi!



Bitte antworten an "Gerrit P. Haase" <gerrit@familiehaase.de>
Gesendet von:   cygwin-owner@cygwin.com
An:     David Starks-Browning <starksb@ebi.ac.uk>
Kopie:  cygwin@cygwin.com 
Thema:  Re: Bash Here - Start Cygwin from a folders context menu

>> I'd like it to work before I reference it in the FAQ.

Fine!

> Well, it was some fiddeling.
> It worked well but now as I tried
> to reinstall, it doesn't work on
> mounted drives anymore:-(

I've done it some time ago. Here's what I did:

first I took a close look on how others where dooing it. Then created a 
file:
--- start of "bash-here.reg" ---
REGEDIT4

[HKEY_CLASSES_ROOT\Drive\shell\bashHere]
@="Shell: bash prompt here"

[HKEY_CLASSES_ROOT\Drive\shell\bashHere\command]
@="C:\\Programme\\Cygwin\\cygwin.bat \"%1\""


[HKEY_CLASSES_ROOT\Directory\shell\bashHere]
@="Shell: bash prompt here"

[HKEY_CLASSES_ROOT\Directory\shell\bashHere\command]
@="C:\\Programme\\Cygwin\\cygwin.bat \"%1\""
--- end of "bash-here.reg" ---


Next "cygwin.bat" was modified:
--- start of "cygwin.bat" ---
@echo off

C:
chdir \Programme\cygwin\bin
echo cd %1 | sed -e "s#\(.\):\(.*\)#/cygdrive/\1\2#" -e "s#\\\\#/#g" > 
%HOMEDRIVE%\.bashcd

bash --login -i
--- end of "cygwin.bat" ---


And last a change to "/etc/profile":
--- start of "/etc/profile" ---
PATH="/usr/local/bin:/usr/bin:/bin:$PATH"

USER="`id -un`"

# Set up USER's home directory
if [ -z "$HOME" ]; then
  HOME="/home/$USER"
fi

if [ ! -d "$HOME" ]; then
  mkdir -p "$HOME"
fi

export HOME USER

for i in /etc/profile.d/*.sh ; do
  if [ -f $i ]; then
    . $i
  fi
done

export MAKE_MODE=unix
export PS1='\[\033]0;\w\007
\033[32m\]\u@\h \[\033[33m\w\033[0m\]
$ '

cd "$HOME"

test -f ./.bashrc && . ./.bashrc
test -f ./.bashcd && . ./.bashcd && rm -f $HOME/.bashcd
--- end of "/etc/profile" ---


Since I am using tcsh too, I've done it for tcsh too:
--- start of "tcsh-here.reg" ---
REGEDIT4

[HKEY_CLASSES_ROOT\Drive\shell\cshHere]
@="Shell: tcsh prompt here"

[HKEY_CLASSES_ROOT\Drive\shell\cshHere\command]
@="C:\\Programme\\cygwin\\bat\\tcsh.bat \"%1\""


[HKEY_CLASSES_ROOT\Directory\shell\cshHere]
@="Shell: tcsh prompt here"

[HKEY_CLASSES_ROOT\Directory\shell\cshHere\command]
@="C:\\Programme\\cygwin\\bat\\tcsh.bat \"%1\""
--- end of "tcsh-here.reg" ---


--- start of "tcsh.bat" ---
@echo off

C:
chdir \Programme\cygwin\bin
echo cd %1 | sed -e "s#\(.\):\(.*\)#/cygdrive/\1\2#" -e "s#\\\\#/#g" > 
%HOMEDRIVE%\.bashcd

tcsh -l
--- end of "tcsh.bat" ---

--- start of "/etc/csh.login" ---
#
# Example /etc/csh.login for Cygwin
#
unsetenv TEMP
unsetenv TMP

set path=( /usr/local/bin /usr/bin /bin $path )

if ( ! ${?USER} ) then
  set user="`id -un`"
endif
if ( ! ${?HOME} ) then
  set home=/home/$USER
endif
if ( ! -d "$HOME" ) then
  mkdir -p "$HOME"
endif

if ( ! ${?TERM} || "$TERM" == "unknown"  || "$tty" == "conin" ) then
  set TERM=linux
endif

setenv MAKE_MODE unix

umask 022

cd ~
if ( -f ".bashcd" ) then
  source ./.bashcd
  rm -f "$HOME/.bashcd"
endif
--- end of "/etc/csh.login" ---


For W2K cmd.exe it is less complicated. You only need registry settings 
since it is not neccessary to replace '\' with '/' and substitute 'c:' 
with '/cygdrive/c' and there is an option telling cmd.exe to execute a 
commandline given command, then go to interactive mode:
--- start of "cmd-here.reg" ---
REGEDIT4

[HKEY_CLASSES_ROOT\Drive\shell\DosHere]
@="Shell: CMD &prompt here"

[HKEY_CLASSES_ROOT\Drive\shell\DosHere\Command]
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%1\""

[HKEY_CLASSES_ROOT\Directory\shell\DosHere]
@="Shell: CMD &prompt here"

[HKEY_CLASSES_ROOT\Directory\shell\DosHere\Command]
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%1\""
--- end of "cmd-here.reg" ---


Neccessary changes for zsh I leave upto the reader ;-)

-- 
Thomas


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28 10:57 Bash Here - Start Cygwin from a folders context menu Thomas Schweikle
@ 2002-05-29 11:20 ` Peter A. Castro
  0 siblings, 0 replies; 15+ messages in thread
From: Peter A. Castro @ 2002-05-29 11:20 UTC (permalink / raw)
  To: cygwin

On Tue, 28 May 2002, Thomas Schweikle wrote:

> Hi!

Hi back at you !-)

> Bitte antworten an "Gerrit P. Haase" <gerrit@familiehaase.de>
> Gesendet von:   cygwin-owner@cygwin.com
> An:     David Starks-Browning <starksb@ebi.ac.uk>
> Kopie:  cygwin@cygwin.com 
> Thema:  Re: Bash Here - Start Cygwin from a folders context menu
> 
> >> I'd like it to work before I reference it in the FAQ.
> 
> Fine!
> 
> > Well, it was some fiddeling.
> > It worked well but now as I tried
> > to reinstall, it doesn't work on
> > mounted drives anymore:-(
[snip]
> Neccessary changes for zsh I leave upto the reader ;-)

... and here you go (pretty simply, really):

--- start of "zsh-here.reg" ---
REGEDIT4

[HKEY_CLASSES_ROOT\Drive\shell\zshHere]
@="Shell: zsh prompt here"

[HKEY_CLASSES_ROOT\Drive\shell\zshHere\command]
@="C:\\Programme\\Cygwin\\cygwin.bat \"%1\""


[HKEY_CLASSES_ROOT\Directory\shell\zshHere]
@="Shell: zsh prompt here"

[HKEY_CLASSES_ROOT\Directory\shell\zshHere\command]
@="C:\\Programme\\Cygwin\\cygwin.bat \"%1\""
--- end of "zsh-here.reg" ---

--- start of "cygwin.bat" ---
@echo off

C:
chdir \Programme\cygwin\bin
echo cd %1 | sed -e "s#\(.\):\(.*\)#/cygdrive/\1\2#" -e "s#\\\\#/#g" > %HOMEDRIVE%\.zshcd

zsh -l -i
--- end of "cygwin.bat" ---

--- start of "/etc/zprofile" ---
PATH="/usr/local/bin:/usr/bin:/bin:$PATH"

USER="`id -un`"

# Set up USER's home directory
if [ -z "$HOME" ]; then
  HOME="/home/$USER"
fi

if [ ! -d "$HOME" ]; then
  mkdir -p "$HOME"
fi

export HOME USER

for i in /etc/profile.d/*.sh ; do
  if [ -f $i ]; then
    . $i
  fi
done

export MAKE_MODE=unix
export PS1='(%n@%m)[%h] %~ $ '

cd "$HOME"

test -f ./.zshcd && . ./.zshcd && rm -f $HOME/.zshcd
--- end of "/etc/zprofile" ---

> For W2K cmd.exe it is less complicated. You only need registry settings 
> since it is not neccessary to replace '\' with '/' and substitute 'c:' 
> with '/cygdrive/c' and there is an option telling cmd.exe to execute a 
> commandline given command, then go to interactive mode:

--- start of "cmd-here.reg" ---
REGEDIT4

[HKEY_CLASSES_ROOT\Drive\shell\DosHere]
@="Shell: CMD &prompt here"

[HKEY_CLASSES_ROOT\Drive\shell\DosHere\Command]
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%1\""

[HKEY_CLASSES_ROOT\Directory\shell\DosHere]
@="Shell: CMD &prompt here"

[HKEY_CLASSES_ROOT\Directory\shell\DosHere\Command]
@="C:\\WINNT\\System32\\cmd.exe /k cd \"%1\""
--- end of "cmd-here.reg" ---

-- 
Peter A. Castro <doctor@fruitbat.org> or <Peter.Castro@oracle.com>
	"Cats are just autistic Dogs" -- Dr. Tony Attwood


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
@ 2002-10-03  4:41 glen.coakley
  0 siblings, 0 replies; 15+ messages in thread
From: glen.coakley @ 2002-10-03  4:41 UTC (permalink / raw)
  To: cygwin

>> 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].
>
>Yes, sure.  It was a little mess with cleaning up .bashrc all the time;)
>I'll look to get it up to the server this weekend.
>
>Someone who is using tcsh and zsh needs to assist me in testing since
>I'm not using these two (yet).
>
>If I get it right now it is still not possible to get two extensions at
>the same time?  So if I want to have a 'bash Prompt Here' (cmd shell) and
>a 'rxvt Prompt Here' I'll need two different startup files?

I added these updates to my own archive including allowing any number of the
'extensions' to be installed at once and uninstalled separately. A .inf file
is built on-the-fly for each extension.

I also fixed the uninstall so that it doesn't leave the extra registry keys
around. This seems to be a bug from the original DOS Prompt Here power toy.

The file is available at www.glencoakley.org. Enter the site and find the
Cygwin link. I don't recommend linking directly to it because my site host
has changed twice since this I created this and I am trying to set up a
system to host it myself. But, I own the domain and don't plan on changing
that.

You will find that the old link below still works but has NOT been updated.
This is because I don't have an account with that ISP anymore but they
haven't bothered to purge the files yet.

>>> Fetch the original from Glen Coakley:
>>> http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html

I am not on the list so please send/copy any replies to me directly.

Glen

--------------------------------------
Glen Coakley, Senior Software Engineer
WebSite: www.GlenCoakley.org


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-30 17:54 Kilroy, David
@ 2002-05-30 19:20 ` Gerrit P. Haase
  0 siblings, 0 replies; 15+ messages in thread
From: Gerrit P. Haase @ 2002-05-30 19:20 UTC (permalink / raw)
  To: Kilroy, David; +Cc: cygwin

Hallo David,

Am Donnerstag, 30. Mai 2002 um 20:59 schriebst du:


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

Yes, sure.  It was a little mess with cleaning up .bashrc all the time;)
I'll look to get it up to the server this weekend.

Someone who is using tcsh and zsh needs to assist me in testing since
I'm not using these two (yet).

If I get it right now it is still not possible to get two extensions at
the same time?  So if I want to have a 'bash Prompt Here' (cmd shell) and
a 'rxvt Prompt Here' I'll need two different startup files?


> Dave.

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


>> From: Gerrit P. Haase [mailto:freeweb@nyckelpiga.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




-- 
=^..^=


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: Bash Here - Start Cygwin from a folders context menu
@ 2002-05-30 17:54 Kilroy, David
  2002-05-30 19:20 ` Gerrit P. Haase
  0 siblings, 1 reply; 15+ messages in thread
From: Kilroy, David @ 2002-05-30 17:54 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]


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@nyckelpiga.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


[-- Attachment #2: cphinf.diff --]
[-- Type: application/octet-stream, Size: 606 bytes --]

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

[-- Attachment #3: install.diff --]
[-- Type: application/octet-stream, Size: 5860 bytes --]

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


[-- Attachment #4: Type: text/plain, Size: 214 bytes --]

--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28 13:30     ` Michael A Chase
@ 2002-05-28 13:37       ` David T-G
  0 siblings, 0 replies; 15+ messages in thread
From: David T-G @ 2002-05-28 13:37 UTC (permalink / raw)
  To: CygWin Users' List; +Cc: Michael A Chase

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]

Michael, et al --

...and then Michael A Chase said...
% 
% On Tue, 28 May 2002 09:08:40 -0500 David T-G <davidtg-cygwin@justpickone.org> wrote:
% 
% > ...and then Michael Hoffman said...
% > % 
% > % On Mon, 27 May 2002, Martin Gramatke wrote:
% > % 
% > ...
% > % > The three installation steps, as described at the end of this
% > posting,
% > % > works but it is not perfect.
% > % 
% > % You might have better results with the attached registry file. You
% > need to
% > 
% > It sounds quite cool.  I'd like to try it myself.  I'll need to poke at
% > it a bit, though; for one thing, I don't have rxvt.
% > 
% > Unfortunately, I can't read it :-)  Can you repost it in .ini format?
% 
% This has come up often enough that a FAQ entry probably would be
% worthwhile.

So I see from the various followups.  Apparently there are lots of ways
to have a BashPromptHere :-)


% 
% For complete coverage, commands are needed for both Directory and
% Drive  The commands also need to be modified if the executable isn't in
% c:\cygwin\bin\.  Because of the extra 'exec' call these startups are

Right; I figured that, too, since mine certainly isn't (util stuff goes
under c:\utils; there's very little cluttering up my root dir :-)


% slightly slower than some of the other suggestions, but no changes are
% needed in cygwin.bat or /etc/profile.

That's good.


% 
% I am not the original source of the command lines, but I no longer recall
% who posted them to cygwin@cygwin.com.
% 
% I don't use rxvt.exe myself.  I have made sure the commands below actually
% start it, but there are probably better options available for rxvt.exe.

Thanks a bunch!


:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) davidtg@justpickone.org * than to live up to them. -- fortune cookie
(work) davidtgwork@justpickone.org
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28 10:20   ` David T-G
@ 2002-05-28 13:30     ` Michael A Chase
  2002-05-28 13:37       ` David T-G
  0 siblings, 1 reply; 15+ messages in thread
From: Michael A Chase @ 2002-05-28 13:30 UTC (permalink / raw)
  To: David T-G, CygWin Users' List

On Tue, 28 May 2002 09:08:40 -0500 David T-G <davidtg-cygwin@justpickone.org> wrote:

> Michael --
> 
> ...and then Michael Hoffman said...
> % 
> % On Mon, 27 May 2002, Martin Gramatke wrote:
> % 
> ...
> % > The three installation steps, as described at the end of this
> posting,
> % > works but it is not perfect.
> % 
> % You might have better results with the attached registry file. You
> need to
> 
> It sounds quite cool.  I'd like to try it myself.  I'll need to poke at
> it a bit, though; for one thing, I don't have rxvt.
> 
> Unfortunately, I can't read it :-)  Can you repost it in .ini format?

David,

This has come up often enough that a FAQ entry probably would be
worthwhile.

For complete coverage, commands are needed for both Directory and
Drive  The commands also need to be modified if the executable isn't in
c:\cygwin\bin\.  Because of the extra 'exec' call these startups are
slightly slower than some of the other suggestions, but no changes are
needed in cygwin.bat or /etc/profile.

I am not the original source of the command lines, but I no longer recall
who posted them to cygwin@cygwin.com.

I don't use rxvt.exe myself.  I have made sure the commands below actually
start it, but there are probably better options available for rxvt.exe.

=======

How do I add Cygwin to folder context menus?

To have Windows Explorer start a Bash console or rxvt window in any
directory, save the. following lines to a file with a .reg extention,
change the command lines to point to where bash.exe and rxvt.exe are
installed, and run the file.

You can change the string that appears in the context menu by changing
"&Bash This" or "rxvt Here" to your prefered string.  The character after
'&' is the shortcut key for the command.

Run 'man rxvt' to see the options available for customizing the rxvt
window.

REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\BashHere]
@="&Bash This"

[HKEY_CLASSES_ROOT\Directory\shell\BashHere\command]
@="c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash -rcfile ~/.bashrc\""

[HKEY_CLASSES_ROOT\Drive\shell\BashHere]
@="&Bash This"

[HKEY_CLASSES_ROOT\Drive\shell\BashHere\command]
@="c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash -rcfile ~/.bashrc\""

[HKEY_CLASSES_ROOT\Directory\shell\rxvt]
@="rxv&t Here"

[HKEY_CLASSES_ROOT\Directory\shell\rxvt\command]
@="C:\\cygwin\\bin\\rxvt.exe -bg black -fg white -sr -sl 1000 -fn \"Fixedsys\" -ls -e /usr/bin/bash --login -c \"cd '%1'; exec /bin/bash -rcfile ~/.bashrc\""

[HKEY_CLASSES_ROOT\Drive\shell\rxvt]
@="rxv&t Here"

[HKEY_CLASSES_ROOT\Drive\shell\rxvt\command]
@="C:\\cygwin\\bin\\rxvt.exe -bg black -fg white -sr -sl 1000 -fn \"Fixedsys\" -ls -e /usr/bin/bash --login -c \"cd '%1'; exec /bin/bash -rcfile ~/.bashrc\""

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.



--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  9:30       ` Gerrit P. Haase
@ 2002-05-28 10:52         ` Gerrit P. Haase
  0 siblings, 0 replies; 15+ messages in thread
From: Gerrit P. Haase @ 2002-05-28 10:52 UTC (permalink / raw)
  To: David Starks-Browning, cygwin

Gerrit schrieb:

>>> I have s.th. similar working on drives and folders.
>>> Glen Coakley has zipped up some files at his website.
>>> As I fetched them, it needed some tweaking to get it running,
>>> but it is the most complete solution for this issue I found.
>>> http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html

>> Gerrit,

>> Thanks for this pointer.  Do you remember what "tweaks" you made?  I'd
>> like to put something in the Cygwin FAQ about this.  This looks
>> useful, but I'd like it to work before I reference it in the FAQ.

>> If you feel the details are off-topic for the list, feel free to reply
>> to me directly.

> Well, it was some fiddeling.
> It worked well but now as I tried
> to reinstall, it doesn't work on
> mounted drives anymore:-(

> It will need a closer look (again).

Ok. It seems to work again.
(Little) Announcement:

I have updated the CygwinPromptHere package.

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
Size: 4k

To install it:
unpack the source: 
$ tar xvzf CygwinPromptHere-20020528.tar.gz
$ cd CygwinPromptHere
$ ./install

Have Fun!


Gerrit
-- 
=^..^=


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  2:59 ` Michael Hoffman
  2002-05-28  4:32   ` Martin Gramatke
  2002-05-28  8:30   ` Gerrit P. Haase
@ 2002-05-28 10:20   ` David T-G
  2002-05-28 13:30     ` Michael A Chase
  2 siblings, 1 reply; 15+ messages in thread
From: David T-G @ 2002-05-28 10:20 UTC (permalink / raw)
  To: CygWin Users' List

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Michael --

...and then Michael Hoffman said...
% 
% On Mon, 27 May 2002, Martin Gramatke wrote:
% 
...
% > The three installation steps, as described at the end of this posting,
% > works but it is not perfect.
% 
% You might have better results with the attached registry file. You need to

It sounds quite cool.  I'd like to try it myself.  I'll need to poke at
it a bit, though; for one thing, I don't have rxvt.

Unfortunately, I can't read it :-)  Can you repost it in .ini format?


TIA & HAND

:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) davidtg@justpickone.org * than to live up to them. -- fortune cookie
(work) davidtgwork@justpickone.org
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  9:14     ` David Starks-Browning
@ 2002-05-28  9:30       ` Gerrit P. Haase
  2002-05-28 10:52         ` Gerrit P. Haase
  0 siblings, 1 reply; 15+ messages in thread
From: Gerrit P. Haase @ 2002-05-28  9:30 UTC (permalink / raw)
  To: David Starks-Browning; +Cc: cygwin

David schrieb:

> On Tuesday 28 May 02, Gerrit P. Haase writes:
>> It doesn't work on drives.  Just on folders.
>> I have s.th. similar working on drives and folders.
>> Glen Coakley has zipped up some files at his website.
>> As I fetched them, it needed some tweaking to get it running,
>> but it is the most complete solution for this issue I found.
>> http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html

> Gerrit,

> Thanks for this pointer.  Do you remember what "tweaks" you made?  I'd
> like to put something in the Cygwin FAQ about this.  This looks
> useful, but I'd like it to work before I reference it in the FAQ.

> If you feel the details are off-topic for the list, feel free to reply
> to me directly.

Well, it was some fiddeling.
It worked well but now as I tried
to reinstall, it doesn't work on
mounted drives anymore:-(

It will need a closer look (again).


Gerrit
-- 
=^..^=


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  8:30   ` Gerrit P. Haase
@ 2002-05-28  9:14     ` David Starks-Browning
  2002-05-28  9:30       ` Gerrit P. Haase
  0 siblings, 1 reply; 15+ messages in thread
From: David Starks-Browning @ 2002-05-28  9:14 UTC (permalink / raw)
  To: Gerrit P. Haase; +Cc: cygwin

On Tuesday 28 May 02, Gerrit P. Haase writes:
> It doesn't work on drives.  Just on folders.
> I have s.th. similar working on drives and folders.
> Glen Coakley has zipped up some files at his website.
> As I fetched them, it needed some tweaking to get it running,
> but it is the most complete solution for this issue I found.
> http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html

Gerrit,

Thanks for this pointer.  Do you remember what "tweaks" you made?  I'd
like to put something in the Cygwin FAQ about this.  This looks
useful, but I'd like it to work before I reference it in the FAQ.

If you feel the details are off-topic for the list, feel free to reply
to me directly.

Thanks,
David
(Cygwin FAQ maintainer)


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  2:59 ` Michael Hoffman
  2002-05-28  4:32   ` Martin Gramatke
@ 2002-05-28  8:30   ` Gerrit P. Haase
  2002-05-28  9:14     ` David Starks-Browning
  2002-05-28 10:20   ` David T-G
  2 siblings, 1 reply; 15+ messages in thread
From: Gerrit P. Haase @ 2002-05-28  8:30 UTC (permalink / raw)
  To: cygwin

Michael schrieb:

> On Mon, 27 May 2002, Martin Gramatke wrote:

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

> You might have better results with the attached registry file. You need to
> have rxvt and bash installed. Other than that, it is a one-step
> installation and you don't need to edit any other files. It avoids using
> COMMAND.COM. (And you might want to consider trying CMD.EXE instead when
> you want such a thing--it will use long filenames and has many other
> useful features lacking in COMMAND.COM.) It will also give you paths like
> /cygdrive/c/Program Files/ instead of C:/Program Files/. Whether you want
> this or not is another question.

It doesn't work on drives.  Just on folders.
I have s.th. similar working on drives and folders.
Glen Coakley has zipped up some files at his website.
As I fetched them, it needed some tweaking to get it running,
but it is the most complete solution for this issue I found.
http://www.users.qwest.net/~weissj/Cygwin/CygwinAddons.html


Gerrit
-- 
=^..^=


--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  2:59 ` Michael Hoffman
@ 2002-05-28  4:32   ` Martin Gramatke
  2002-05-28  8:30   ` Gerrit P. Haase
  2002-05-28 10:20   ` David T-G
  2 siblings, 0 replies; 15+ messages in thread
From: Martin Gramatke @ 2002-05-28  4:32 UTC (permalink / raw)
  To: cygwin

On Mon, 27 May 2002 16:16:05 -0500 (Central Daylight Time), you wrote:

>On Mon, 27 May 2002, Martin Gramatke wrote:

>>"Bash Here" should
>> start a cygwin bash shell from a folders context menu.

>You might have better results with the attached registry file. You need to
>have rxvt and bash installed. Other than that, it is a one-step...

That is exactly what I was looking for. It works great (I had to
convert the .reg to a DOS text file). Thank you so much!

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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Bash Here - Start Cygwin from a folders context menu
  2002-05-28  1:41 Martin Gramatke
@ 2002-05-28  2:59 ` Michael Hoffman
  2002-05-28  4:32   ` Martin Gramatke
                     ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Michael Hoffman @ 2002-05-28  2:59 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: TEXT/PLAIN, Size: 985 bytes --]

On Mon, 27 May 2002, Martin Gramatke wrote:

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

You might have better results with the attached registry file. You need to
have rxvt and bash installed. Other than that, it is a one-step
installation and you don't need to edit any other files. It avoids using
COMMAND.COM. (And you might want to consider trying CMD.EXE instead when
you want such a thing--it will use long filenames and has many other
useful features lacking in COMMAND.COM.) It will also give you paths like
/cygdrive/c/Program Files/ instead of C:/Program Files/. Whether you want
this or not is another question.

I called the key 0cmd-rxvt so it would show up before other menu items.

Share and enjoy.
-- 
Michael Hoffman <grouse@mail.utexas.edu>
The University of Texas at Austin

[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 654 bytes --]

[-- Attachment #3: Type: text/plain, Size: 214 bytes --]

--
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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Bash Here - Start Cygwin from a folders context menu
@ 2002-05-28  1:41 Martin Gramatke
  2002-05-28  2:59 ` Michael Hoffman
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Gramatke @ 2002-05-28  1:41 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-10-03 11:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-28 10:57 Bash Here - Start Cygwin from a folders context menu Thomas Schweikle
2002-05-29 11:20 ` Peter A. Castro
  -- strict thread matches above, loose matches on Subject: below --
2002-10-03  4:41 glen.coakley
2002-05-30 17:54 Kilroy, David
2002-05-30 19:20 ` Gerrit P. Haase
2002-05-28  1:41 Martin Gramatke
2002-05-28  2:59 ` Michael Hoffman
2002-05-28  4:32   ` Martin Gramatke
2002-05-28  8:30   ` Gerrit P. Haase
2002-05-28  9:14     ` David Starks-Browning
2002-05-28  9:30       ` Gerrit P. Haase
2002-05-28 10:52         ` Gerrit P. Haase
2002-05-28 10:20   ` David T-G
2002-05-28 13:30     ` Michael A Chase
2002-05-28 13:37       ` David T-G

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).