Implement autoenv unload #30

Open
turicas opened this Issue Aug 11, 2012 · 19 comments

Comments

Projects
None yet

turicas commented Aug 11, 2012

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:

mkdir spam
echo "workon spam" > spam/.env
echo "deactivate" > spam/.env-unload
cd spam # run `source .env`, activating virtualenv 'spam'

# working in this directory...
mkdir eggs
cd eggs
touch ham
cd ..
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.

Owner

kennethreitz commented Aug 11, 2012

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.

Owner

kennethreitz commented Aug 14, 2012

I'll leave this issue open for discussion.

kennethreitz reopened this Aug 14, 2012

I like the idea.

+1

Bankq commented Nov 17, 2012

I'd love if I can put it in .env with separate parts. Like

[load]
...
...
...

[unload]
...
...

bahoo commented Nov 24, 2012

+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
    deactivate
fi

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.

Contributor

blueyed commented Sep 30, 2014

FYI: smartcd supports this.

+1 for the unload feature.

+1

Contributor

blueyed commented Oct 20, 2015

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).

Atry commented May 5, 2016

+1

dasJ added the type/feature label Aug 1, 2016

dasJ added this to the 0.3.0 milestone Aug 6, 2016

luizs81 commented Aug 9, 2016

+1

dasJ referenced this issue Aug 26, 2016

Open

Rewrite the main loop #129

0 of 5 tasks complete

@dasJ dasJ modified the milestone: 0.4.0, 0.3.0 Sep 7, 2016

aliavni commented Dec 26, 2016

+1

SashaOv commented Dec 26, 2016

I would suggest documenting the workaround by @kazagistar above somewhere in README. It could be useful for many people

ujuc referenced this issue in ujuc/ujuc.github.io Jan 21, 2017

Closed

autoenv 설정 한거 남겨둘것 #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment