Subject: Re: Bash Here - Start Cygwin from a folders context menu
From: "Thomas Schweikle" <[email-masked]>
To: "Gerrit P. Haase" <[email-masked]>
Cc: [email-masked]
Date: Tue, 28 May 2002 17:18:54 +0200

Hi!

Bitte antworten an "Gerrit P. Haase" <[email-masked]>
Gesendet von:   [email-masked]
An:     David Starks-Browning <[email-masked]>
Kopie:  [email-masked] 
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/