Skip to content

alanbbr/direnv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

direnv -- Unclutter your .profile

direnv is a shell extension that loads different environment variables depending on your path.

Instead of putting every environment variable in your "~/.profile", have directory-specific ".envrc" files for your AWS_ACCESS_KEY, LIBRARY_PATH or other environment variables.

It does some of the job of rvm, rbenv or virtualenv but in a language-agnostic way.

Example

$ cd ~/code/my_project
$ ls
bin/ lib/ Rakefile README.md
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
$ direnv edit .
# Opens in your `$EDITOR .envrc`. Add:
export PATH=$PWD/bin:$PATH
$
direnv: loading .envrc
direnv export: ~PATH
$ echo $PATH
/Users/zimbatm/code/my_project/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
$ cd ..
direnv: unloading
direnv export: ~PATH
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

Install

1. Install the code

git clone http://github.com/zimbatm/direnv
cd direnv
make install
# or symlink bin/direnv into your $PATH

For Mac users, you can also use brew install direnv

2. Add the hook for your shell

This is what is going to enable the direnv extension. Add this line at the very end of your .bashrc or .zshrc:

eval "$(direnv hook $0)"

Make sure it appears even after rvm, git-prompt and other shell extensions that manipulate your prompt.

Usage

Use direnv edit . to open an ".envrc" in your $EDITOR. This script is going to be executed once you exit the editor. Every export is going to be available in your shell until you cd .. out of the directory.

To make your life convenient there is a couple of additional commands in the .envrc execution context that are loaded from the direnv stdlib.

Contribute

Bug reports, contributions and forks are welcome.

For bugs, report them on http://github.com/zimbatm/direnv/issues

Or if you have some cool usages of direnv that you want to share, feel free to put them in the wiki https://github.com/zimbatm/direnv/wiki

Build Status

COPYRIGHT

Thank you for making direnv better

  • Alexander Kobel for his patches
  • Brian M. Clapper (aka. bmc) for his patch
  • Joshua Peek (aka. josh) for his patch and support
  • Laurie Young (aka. wildfalcon) for fixing my engrish
  • Magnus Holm (aka. judofyr) for his patches and ideas
  • Martin Aumüller (aka. aumuell) for his patches and awesomeness
  • Peter Waller (aka. pwaller) for his patches and insights
  • Sam Stephenson (aka. sstephenson) for his expand_path code that I stole from https://github.com/sstephenson/bats

Copyright (C) 2013 Jonas Pfenniger and contributors under the MIT licence.

About

Unclutter your .profile

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 90.3%
  • Shell 8.2%
  • Ruby 1.5%