autoenv
autoenv copied to clipboard
Can I deactivate used env if I cd to folder
Could current activated env be deactivated if I cd to folder which is not subfolder of current directory?
Also if I using such .env: source oenv/bin/activate it works when I enter to this folder, but then when I go to subfolder I'm getting: bash: oenv/bin/activate: No such file or directory I can fix it using absolute path, but it will be activated twice, isn't it.
This would be nice, but since the scope of .env right now is "any bash script", it's not really an easy thing to do.
We could reset environment variables to their original state.
Agreed that this would be a good feature. What if you cd to a directory containing a .env, and then cd to another directory containing another .env? Maybe you want the cumulative effects of the two envs, but probably not.
I have similar sort of project that handles deactivating envs: https://bitbucket.org/krupan/albion/wiki/Home
Feel free to copy any of it, or to tell me it's stupid :-)
:+1:
+1
:+1: for resetting environment variables.
@kennethreitz Limiting the scope for environment variables only (not any bash script) sounds good, but dramatically changes the functionality of autoenv, right?
Correct.
How about calling a tear down function (on_leave?) if it is defined in .env? For example, to deactivate a condo environment one might define this function in .env.
function on_leave() {
echo "Deactivating environment"
source deactivate
}
I haven't considered the details but would something like this be useful?
i mkdir "dac" a directory and touch .env with the line in the "dac"
deactivate cd ..
now i can cd dac and deactivate and back
Closing as this has been implemented in v0.3.0 with the .env.leave file. It's not perfect and you would have to manually "deactive" the environment you have setup (i am keeping autoenv as simple as possible), but it is what you would if you want to do this. Sorry for the pings - I know this is an old thread.