In general I use autoenv to automatically activate my Python virtualenvs. It works pretty nice, but I miss a feature to automatically deactivate the virtualenv. It should deactivate the virtualenv if I change the directory to a path that is not inside the path which enabled the virtualenv. For example:
echo "workon spam" > spam/.env
echo "deactivate" > spam/.env-unload
cd spam # run `source .env`, activating virtualenv 'spam'
# working in this directory...
echo "finished" > README.markdown
# finished working.
cd .. # runs `source .env-unload`, deactivating virtualenv
Another approach is to define bash functions inside .env (like autoenv_load and autoenv_unload) and call these functions instead of just sourcing .env/.env-unload.
Yeah, I've considered this for a while, but decided it's out of scope (for now).
Thanks for the suggestions though, I'll definitely consider them in the future.
I'll leave this issue open for discussion.
I like the idea.
I'd love if I can put it in .env with separate parts. Like
+1. I do see how it qualifies as out of scope, but I'd use an add-on (or completely separate) tool for handling unloading, if it existed.
Simple workaround: place this .env somewhere high in your directory tree (possibly in the root)
if [ -n "$VIRTUAL_ENV" ] ; then
I am sure there are some horrible side effects I am not taking into consideration, but it works for me. <_<
I do hope you change you mind about this issue, but cool project anyway.
Awesome project. I would love to see this one feature added as well.
FYI: smartcd supports this.
+1 for the unload feature.
FYI: zsh-autoenv also supports this, either through a separate or the same file (where you can look at a variable to see which event it is).
I would suggest documenting the workaround by @kazagistar above somewhere in README. It could be useful for many people