[CentOS] Autorun ability on cd?

Wed Aug 5 13:49:04 UTC 2009
James B. Byrne <byrnejb at harte-lyne.ca>

I have a little niggling situation that I would like to resolve
programmatically.  I use Git as my SCM and I have release branches
which are sometimes patched.  I find myself sometimes entering the
working directory tree forgetting that I was last on a release
branch and not on the master.

What I would like to do is to have a script run every time that I
enter a directory, check for .git, and if it finds it then simply do
a git-branch for me so that which I am on is forcefully pointed out
to me before I proceed to do something foolish.

All I can come up with from searching wrt cd is details on why one
cannot change the working directory of a running script and various
kluges around this.  I do not wish to change the pwd of the shell, I
just want some way of testing for a certain file and running a
specific command if it is found when I enter a working tree. If this
requires testing every directory that I cd to then I can live with
that.  If instead one can put a script that runs only when one
enters certain directories then I can live with that as well.

Is there any way to do this?

-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3