Possible Duplicate:
Execute bash scripts on entering a directory
I am running an environment which requires some very specific tool versions.
The commands to set up the environment are in a script called set_foo_env.sh
Suppose I have a directory ~/repository/foo/. Is is possible to run set_foo_env.sh as soon as I enter the foo directory?

cdalthough this is my personal opinion. Thanks for your comment though. – boffin Jul 10 '12 at 15:57PROMPT_COMMANDbased solution will run the command after each command executed inside the specified directory. So if you docd ~/repository/foo/,du -schanddate, then set_foo_env.sh will be executed 3 times. Thecdaliasing solution will execute it only once. – manatwork Jul 10 '12 at 16:22