-
Notifications
You must be signed in to change notification settings - Fork 1
/
.direnvrc
45 lines (33 loc) · 1.14 KB
/
.direnvrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use_ruby() {
source /usr/local/opt/chruby/share/chruby/chruby.sh
local ver=$1
if [[ -z $ver ]] && [[ -f .ruby-version ]]; then
ver=$(cat .ruby-version)
fi
if [[ -z $ver ]]; then
echo Unknown ruby version: need to declare a version in .ruby-version or in .envrc
exit 1
fi
# switch to the desired ruby
chruby $ver
layout ruby
}
use_chefdk() {
# include this function in `~/.direnvrc`
EXPANDED_HOME=`expand_path ~`
# Override the GEM environment
log_status "Overriding default Ruby environment to use ChefDK"
export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
export GEM_HOME="$EXPANDED_HOME/.chefdk/gem/ruby/2.1.0"
export GEM_PATH="$EXPANDED_HOME/.chefdk/gem/ruby/2.1.0:/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
# Ensure ChefDK and it's embedded tools are first in the PATH
log_status "Ensuring ChefDK and it's embedded tools are first in the PATH"
PATH_add $EXPANDED_HOME/.chefdk/gem/ruby/2.1.0/bin/
PATH_add /opt/chefdk/embedded/bin
PATH_add /opt/chefdk/bin
}
use_python() {
local python_root=$HOME/.pyenv/versions/$1
load_prefix "$python_root"
layout_python "$python_root/bin/python"
}