1 Star 0 Fork 0

zbk / autoenv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Autoenv: Directory-based Environments Build Status

Magic per-project shell environments

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:

Image of text history

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

Mind blown GIF

Install

Install it easily:

MacOS using Homebrew

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

Using Git

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

Using npm

Download the @hyperupcall/autoenv package

$ npm install -g '@hyperupcall/autoenv'
$ echo "source \"\$(npm root -g)/@hyperupcall/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 a non-null string 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 a non-null string to silently authorize the initialization of new environments
  • AUTOENV_VIEWER: Program used to display env files prior to authorization. Default: "less -N".

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

Attributions

Autoenv was originally created by @kennethreitz. Ownership was then transfered to @inishchith. As of August 22nd, 2021, Edwin Kofler (@hyperupcall) owns and maintains the project

Copyright (C) 2012 Kenneth Reitz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
Shell 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/hellozbk/autoenv.git
git@gitee.com:hellozbk/autoenv.git
hellozbk
autoenv
autoenv
master

搜索帮助