direnv

DIRENV-STDLIB 1 “APRIL 2014” direnv “User Manuals”

NAME

direnv_stdlib - the “.envrc” stdlib

SYNOPSIS

direnv stdlib

DESCRIPTION

Outputs a bash script called the stdlib. The following commands are included in that script and loaded in the context of an “.envrc”. In addition, it also loads the file in “~/.direnvrc” if it exists.

STDLIB

Example:

if has curl; then
  echo "Yes we do"
fi

Example:

cd /usr/local/games
expand_path ../foo
# output: /usr/local/foo

Example:

echo $HOME
# output: /home/user
user_rel_path /home/user/my/project
# output: ~/my/project
user_rel_path /usr/local/lib
# output: /usr/local/lib

Example:

cd /usr/local/my
mkdir -p project/foo
touch bar
cd project/foo
find_up bar
# output: /usr/local/my/bar

Example:

direnv_load opam-env exec -- direnv dump

Example:

pwd
# output: /home/user/my/project
PATH_add bin
echo $PATH
# output: /home/user/my/project/bin:/usr/bin:/bin

Variables set:

CPATH
LD_LIBRARY_PATH
LIBRARY_PATH
MANPATH
PATH
PKG_CONFIG_PATH

Example:

./configure --prefix=$HOME/rubies/ruby-1.9.3
make && make install
# Then in the .envrc
load_prefix ~/rubies/ruby-1.9.3

Example:

use_ruby() {
  echo "Ruby $1"
}
use ruby 1.9.3
# output: Ruby 1.9.3

Example (.envrc):

set -e
use node

Example (.node-version):

4.2

Example (.envrc):

set -e
use node 4.2.2

Example (.envrc):

watch_file Gemfile

Copyright (C) 2014 zimbatm http://zimbatm.com and contributors under the MIT licence.

SEE ALSO

direnv(1)