I would like to set environmental variables in bash whenever I use a script in the ~/project/bash folder
currently, to run scripts in this folder, I have to run:
cd ~/project/bash
. ./project/bash/env.vars.sh
first, I would like these variables to be automatically set, preferably when either t开发者_如何学Che scripts are used or the user changes to ~/project or therein.
Thanks!
I am not aware of anything that will do something when a script is executed. The closest thing I can see to what you need is to put:
. ./project/bash/env.vars.sh
on the start of each of the scripts.
If that is an option for you, you can create a special user which would have the above line in its ~/.bashrc
, so the environment gets set up automatically on login.
精彩评论