brew install direnv
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
exec bash
Jonas Pfenniger Chevalier IRL
zimbatm everywhere else
@zimbatm on twitter, github, skillmatter, …
Works at on the pubsub messaging product.
25 minutes
brew install direnv
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
exec bash
supports bash, zsh, fish, tcsh and more
packages for homebrew, debian, archlinux and nixos. or just grab the binary.
hook into shell
direnv export
executed before every prompt
* looks for .envrc in the current directory and up
* if found, loads the .envrc in bash and get the ENV diff
* then injects the diff into the current shell (with state serialization)
* otherwise unloads
TODO: mtime, allowed
TODO: decision graph
tldr; cd into director, loads env, cd out, unloads env
~/.config/direnv/allowed/$(hash(path + .envrc content))
woot
demo
use
PATH_add load_prefix dotenv source_env / source_up layout / _ruby use
ruby-install ruby 1.9.3
~/.direnvrc
use_ruby() {
load_prefix "$HOME/.rubies/ruby-$1"
}
.envrc
use ruby 1.9.3-p551
~/.direnvrc
use_ruby-version() {
use ruby "$(< .ruby-version)"
layout ruby
PATH_add bin
}
.envrc
dotenv
use ruby-version
load_brew() {
...
}
or ./configure --prefix=$HOME/.custom/<my-lib>
or use_nix
+ simple, can reason about + language-agnostic + flexible + easy to debug (if you know unix)
/