#!/usr/bin/env bash # Source a .rvmrc file in a directory after changing to it, if it exists. # To disable this fature, set rvm_project_rvmrc=0 in $HOME/.rvmrc if [[ "$rvm_project_rvmrc" -ne 0 ]] ; then cd() { builtin cd "$@" local cwd ; cwd=$(pwd) while : ; do if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then if [[ ! -z "$rvm_rvmrc_cwd" ]] ; then if [[ -z "$rvm_previous_environment" ]] ; then rvm default 1>/dev/null 2>&1 else rvm "$rvm_previous_environment" 1>/dev/null 2>&1 fi unset rvm_rvmrc_cwd rvm_previous_environment fi break else if [[ -f "$cwd/.rvmrc" ]] ; then if [[ "$rvm_rvmrc_cwd" != "$cwd" ]] ; then if [[ -z "$rvm_previous_environment" ]] ; then rvm_previous_environment="$(__rvm_environment_identifier)" fi rvm_rvmrc_cwd="$cwd" source "$cwd/.rvmrc" fi break else cwd=$(dirname "$cwd") fi fi done } fi