delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/09/22/12:13:41

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: Fri, 22 Sep 2000 11:10:04 -0500
From: Jonathan M Merz <merz AT studsys DOT mscs DOT mu DOT edu>
To: Luke Bakken <luke_bakken AT yahoo DOT com>
Cc: cygwin AT sources DOT redhat DOT com
Subject: Re: Bash + Shell hack = ?
Message-ID: <20000922111004.A18946@studsys.mscs.mu.edu>
References: <20000922145540 DOT 16156 DOT qmail AT web114 DOT yahoomail DOT com> <Pine DOT BSO DOT 4 DOT 21 DOT 0009220843450 DOT 13127-100000 AT ics-server DOT interface-net DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.1.5i
In-Reply-To: <Pine.BSO.4.21.0009220843450.13127-100000@ics-server.interface-net.com>; from luke_bakken@yahoo.com on Fri, Sep 22, 2000 at 08:48:04AM -0700

--ZPt4rx8FFjLCG7dd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

I actually was trying to do the same thing a few weeks ago and came up with an ugly hack, but it gets the job done.  The problem is that any time you run a bash --login, it drops you into your home directory, so you actually need to run the cd command _after_ starting the login shell.  The way I managed this is to have a windows batch file call a bash shell script (since I'd rather write shell scripts than batch files) that creates a file containing the cd command to whatever the directory is.  The two files for that are gotodir.bat and gotodir.sh (I've attached them).  Then, I put a check in the bottom of my .bashrc and .profile to see if the file with the cd command exists, and if it does, execute it, then delete it (so that it won't be run if I just want to start a login shell in my home directory.  So, to set it up (I warned you, this is ugly):

1.  put gotodir.sh in your $HOME/bin directory (This can be changed, but you'll have to edit gotodir.bat to do it)
2.  put gotodir.bat anywhere you like, just so you know where it is.
3.  add the following to your .bashrc or .profile:
    test -f ~/.chdirrc && . ~/.chdirrc
    test -f ~/.chdirrc && rm ~/.chdirrc
4.  in the windows registry, add:
    [HKLM]\SOFTWARE\Classes\Folder\shell\Bash Prompt Here   (Make this whatever you want to see in the context menu)
    [HKLM]\SOFTWARE\Classes\Folder\shell\Bash Prompt Here\command

    in the command key, add the string "c:\winnt\system32\cmd.exe /c <path to gotodir.bat>\gotodir.bat"

 Hopefully I have the setup correct there.  If not, let me know what's not working and hopefully I'll be able to correct myself.  And if anyone knows of or can come up with a cleaner way to do this, please let us all know.

 Hope it helps,

 Jon


On Fri, Sep 22, 2000 at 08:48:04AM -0700, Luke Bakken wrote:
> Hi,
> 
> I've got an option for my "File Folder" file type so that if I right-click
> on a folder, I can execute a cmd.exe prompt in that folder:
> 
> cmd.exe /K cd "%1"
> 
> 
> What I'm wondering is if something analogous to the /K switch exists for
> Bash, so that I can run a command before starting the login shell. the
> "-c" option is similar, but the shell exits after running the command
> specified. What I want is for it not to exit.
> 
> Thanks,
> Luke
> 
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
> 

--ZPt4rx8FFjLCG7dd
Content-Type: application/x-msdos-program
Content-Disposition: attachment; filename="gotodir.bat"
Content-Transfer-Encoding: quoted-printable

REM ECHO OFF=0D=0Abash %HOME%\bin\gotodir.sh=0D=0Abash --login -i=0D=0A
--ZPt4rx8FFjLCG7dd
Content-Type: application/x-sh
Content-Disposition: attachment; filename="gotodir.sh"
Content-Transfer-Encoding: quoted-printable

echo cd $PWD >  $HOME/.chdirrc=0D=0Aecho rm .chdirrc >> $HOME/.chdirrc=0D=
=0Aecho clear >> $HOME/.chdirrc=0D=0A

--ZPt4rx8FFjLCG7dd
Content-Type: text/plain; charset=us-ascii

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

- Raw text -


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