GithubHelp home page GithubHelp logo

anthrax3 / autoenv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hyperupcall/autoenv

0.0 1.0 0.0 103 KB

Directory-based environments.

License: MIT License

Makefile 1.86% Shell 95.33% Python 2.82%

autoenv's Introduction

Autoenv: Directory-based Environments

Magic per-project shell environments. Very pretentious.

Note: you should probably use direnv instead. Simply put, it is higher quality software. But, autoenv is still great, too. Maybe try both? :)

This image sums up the relationship between the two projects, very well:

http://share.kennethreitz.org/1u0j2s3M1w36/776204239940493426%3Faccount_id=8.jpg

What is it?

If a directory contains a .env file, it will automatically be executed when you cd into it. When enabled (set AUTOENV_ENABLE_LEAVE to a non-null string), if a directory contains a .env.leave file, it will automatically be executed when you leave it.

This is great for...

  • auto-activating virtualenvs
  • auto-deactivating virtualenvs
  • project-specific environment variables
  • making millions

You can also nest envs within each other. How awesome is that!?

When executing, autoenv, will walk up the directories until the mount point and execute all .env files beginning at the top.

Usage

Follow the white rabbit:

$ echo "echo 'whoa'" > project/.env
$ cd project
whoa

http://media.tumblr.com/tumblr_ltuzjvbQ6L1qzgpx9.gif

Install

Install it easily:

Mac OS X Using Homebrew

$ brew install autoenv
$ echo "source $(brew --prefix autoenv)/activate.sh" >> ~/.bash_profile

Using pip

$ pip install autoenv
$ echo "source `which activate.sh`" >> ~/.bashrc

Using git

$ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv
$ echo 'source ~/.autoenv/activate.sh' >> ~/.bashrc

Using AUR

Arch Linux users can install autoenv or autoenv-git with their favorite AUR helper.

You need to source activate.sh in your bashrc afterwards:

$ echo 'source /usr/share/autoenv/activate.sh' >> ~/.bashrc

Configuration

Before sourcing activate.sh, you can set the following variables:

  • AUTOENV_AUTH_FILE: Authorized env files, defaults to ~/.autoenv_authorized
  • AUTOENV_ENV_FILENAME: Name of the .env file, defaults to .env
  • AUTOENV_LOWER_FIRST: Set this variable to flip the order of .env files executed
  • AUTOENV_ENV_LEAVE_FILENAME: Name of the .env.leave file, defaults to .env.leave
  • AUTOENV_ENABLE_LEAVE: Set this to a non-null string in order to enable source env when leaving
  • AUTOENV_ASSUME_YES: Set this variable to silently authorize the initialization of new environments

Shells

autoenv is tested on:

  • bash
  • zsh
  • dash
  • fish is supported by autoenv_fish
  • more to come

Alternatives

Direnv is an excellent alternative to autoenv, and includes the ability to unset environment variables as well. It also supports the fish terminal.

https://direnv.net

Disclaimer

Autoenv overrides cd. If you already do this, invoke autoenv_init within your custom cd after sourcing activate.sh.

Autoenv can be disabled via unset cd if you experience I/O issues with certain file systems, particularly those that are FUSE-based (such as smbnetfs).

autoenv's People

Contributors

andersdjohnson avatar aschmolck avatar ashokrajar avatar blueyed avatar carhartl avatar chunyang-wen avatar cuonglm avatar dasj avatar davidjb avatar ferrix avatar frankshearar avatar gabrielgrant avatar honzajavorek avatar jaysonsantos avatar joneskoo avatar joshuamorton avatar jsatt avatar kennethreitz avatar kylef avatar mahmoudhossam avatar mkomitee avatar mpapis avatar msztolcman avatar mwarkentin avatar noamt avatar nvie avatar pimuzzo avatar pravj avatar unixorn avatar z4y4ts avatar

Watchers

 avatar

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.