Coder Social home page Coder Social logo

Comments (9)

robcowie avatar robcowie commented on August 17, 2024 4

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?

from autoenv.

kennethreitz avatar kennethreitz commented on August 17, 2024 3

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.

from autoenv.

krupan avatar krupan commented on August 17, 2024

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

from autoenv.

jeantil avatar jeantil commented on August 17, 2024

👍

from autoenv.

hwangmoretime avatar hwangmoretime commented on August 17, 2024

+1

from autoenv.

zambon avatar zambon commented on August 17, 2024

👍 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?

from autoenv.

kennethreitz avatar kennethreitz commented on August 17, 2024

Correct.

from autoenv.

HSin-Tse avatar HSin-Tse commented on August 17, 2024

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

from autoenv.

hyperupcall avatar hyperupcall commented on August 17, 2024

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.

from autoenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.