2012-07-24 09:31:43 +08:00
|
|
|
function rvm -d 'Ruby enVironment Manager'
|
|
|
|
# run RVM and capture the resulting environment
|
|
|
|
set -l env_file (mktemp -t rvm.fish.XXXXXXXXXX)
|
2013-05-25 18:11:13 +08:00
|
|
|
bash -c '[ -e ~/.rvm/scripts/rvm ] && source ~/.rvm/scripts/rvm || source /usr/local/rvm/scripts/rvm; cd .;rvm "$@"; status=$?; env > "$0"; exit $status' $env_file $argv
|
2013-03-02 13:41:22 +08:00
|
|
|
|
2014-09-22 16:34:16 +08:00
|
|
|
# grep the rvm_* *PATH RUBY_* GEM_* variables from the captured environment
|
|
|
|
# exclude lines with _clr and _debug
|
2013-03-02 13:41:22 +08:00
|
|
|
# apply rvm_* *PATH RUBY_* GEM_* variables from the captured environment
|
2014-09-22 16:34:16 +08:00
|
|
|
|
2014-09-22 16:45:55 +08:00
|
|
|
and eval (grep '^rvm\|^[^=]*PATH\|^RUBY_\|^GEM_' $env_file |grep -v _clr |grep -v _debug| sed '/^[^=]*PATH/y/:/ /; s/^/set -xg /; s/=/ /; s/$/ ;/; s/(//; s/)//')
|
2012-07-24 09:31:43 +08:00
|
|
|
|
|
|
|
# clean up
|
|
|
|
rm -f $env_file
|
|
|
|
end
|