/
rvm
executable file
·78 lines (65 loc) · 2.23 KB
/
rvm
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# rvm : Ruby Version Manager
# http://rvm.beginrescueend.com
# http://gitub.com/wayneeseguin/rvm
if [[ "$rvm_loaded_flag" != "1" ]] || [[ "$rvm_reload_flag" = "1" ]] ; then
unset rvm_reload_flag
mkdir -p $HOME/.gem/cache
if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi
if [[ -z "$rvm_prefix" ]] ; then
if [[ "root" = "$(whoami)" ]] ; then
rvm_prefix="/usr/local"
else
rvm_prefix="$HOME"
fi
fi
if [[ -z "$rvm_path" ]] ; then
unset rvm_path
if [[ "root" = "$(whoami)" ]] ; then
rvm_path="$rvm_prefix/rvm"
else
if [[ -d "$HOME/.rvm" ]] && [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
rvm_path="$HOME/.rvm"
elif [[ -d "$rvm_prefix/rvm" ]] && [[ -s "$rvm_prefix/rvm/scripts/rvm" ]] ; then
rvm_path="$rvm_prefix/rvm"
else
rvm_path="$HOME/.rvm"
fi
fi
fi
if [[ -z "$rvm_scripts_path" ]] || [[ ! -d "$rvm_scripts_path" ]] ; then
if [[ -d "$HOME/.rvm/scripts" ]] && [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
rvm_scripts_path="$HOME/.rvm/scripts"
elif [[ -d "$rvm_path/scripts" ]] && [[ -s "$rvm_path/scripts/rvm" ]]; then
rvm_scripts_path="$rvm_path/scripts"
else
if [[ "root" = "$(whoami)" ]] ; then
rvm_scripts_path="/usr/local/rvm"
else
rvm_scripts_path="$HOME/.rvm"
fi
fi
fi
if [[ -d "$rvm_path" ]] ; then
source $rvm_scripts_path/array
source $rvm_scripts_path/utility
source $rvm_scripts_path/initialize
source $rvm_scripts_path/version
source $rvm_scripts_path/selector
source $rvm_scripts_path/cli
source $rvm_scripts_path/cd
rvm_loaded_flag=1
rvm_version="$(cat "${rvm_path}/lib/VERSION.yml" | tail -n 3 | sed 's/^.*: //g' | tr "\n" '.' | sed 's/\.$//')" ; export rvm_version
alias rvm-restart="source '${rvm_path}/scripts/rvm'"
if [[ -s "$HOME/.rvm/default" ]] ; then
source "$HOME/.rvm/default"
elif [[ -s "$rvm_config_path/default" ]] ; then
source "$rvm_config_path/default"
elif [[ -s "$rvm_prefix/rvm/config/default" ]] ; then
source "$rvm_prefix/rvm/config/default"
fi
else
echo -e "\$rvm_path is not set. rvm cannot load."
fi
fi