Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Feature: Project specific rvmrc files now switch back to default and/…

…or system rubies when exiting a project directory.

Additionally they can now be toggled off by placing 'rvm_project_rvmrc_default=0' and/or 'rvm_project_rvmrc=0' in the ~/.rvmrc file
  • Loading branch information...
commit 1a7b8af9beec9d6fbce5f5d7ed32a8b1cd167850 1 parent 710ac66
Wayne E. Seguin authored
Showing with 18 additions and 1 deletion.
  1. +2 −0  scripts/initialize
  2. +16 −1 scripts/rvm
2  scripts/initialize
View
@@ -6,6 +6,8 @@ else
rvm_rc_files="$HOME/.bash_profile $HOME/.bashrc $HOME/.zshrc"
fi
+rvm_project_rvmrc="${rvm_project_rvmrc:-1}"
+rvm_project_rvmrc_default="${rvm_project_rvmrc_default:-1}"
rvm_scripts_path="${rvm_scripts_path:-"$rvm_path/scripts"}"
rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
17 scripts/rvm
View
@@ -40,7 +40,22 @@ if [[ "$rvm_loaded_flag" != "1" ]] || [[ "$rvm_reload_flag" = "1" ]] ; then
if [[ -f "$rvm_path/default" ]] ; then source "$rvm_path/default" ; fi
# Source a .rvmrc file in a directory after changing to it, if it exists.
- cd() { builtin cd "$@" ; if [[ -f .rvmrc ]] ; then source .rvmrc ; fi ; }
+ cd() {
+ builtin cd "$@"
+ if [[ "$rvm_project_rvmrc" != 0 ]] ; then
+ local cwd ; cwd=$(pwd)
+ while : ; do
+ if [[ -f "$cwd/.rvmrc" ]] ; then source "$cwd/.rvmrc" ; break ; fi
+ cwd=$(dirname $cwd)
+ if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then
+ if [[ "$rvm_project_rvmrc_default" != 0 ]] ; then
+ rvm default 1>/dev/null 2>&1
+ fi
+ break
+ fi
+ done
+ fi
+ }
alias rvm-restart="source '${rvm_path}/scripts/rvm'"
fi
Please sign in to comment.
Something went wrong with that request. Please try again.