This question already has an answer here:
Is there a way on *nix machines, to change the value of an environment variable depending on the current working directory?
I am working on an NPM/Node.js module.
Basically what I want to do, is change the path to an executable depending on the
Here is a project root
the executable is in
when I am "within"
/home/user/project, aka in any descendant of that path, then I want the value for the env variable to be the path to x
I have a script that can find x given the current path, but what I need is a way to run that script, every time the user changes directories.
This might slow down the machine a lot though, this type of hook. Is this type of hook possible? Is there a better/different solution?
I think this question is similar: https://superuser.com/questions/914087/can-i-change-my-path-dynamically-based-on-my-cwd