scripts/cd in rvm-0.1.41 vs scripts/cd in rvm-0.1.42
- old
+ new
@@ -1,38 +1,23 @@
#!/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"
- cwd=$(dirname "$cwd")
- fi
- break
- else
- cwd=$(dirname "$cwd")
- fi
- fi
- done
-
- }
+ if [[ -n "$ZSH_VERSION" ]]; then
+ autoload is-at-least
+ if is-at-least 4.3.4 >/dev/null 2>&1; then
+ # On zsh, use chpwd_functions
+ chpwd_functions=( "${chpwd_functions[@]}" __rvm_project_rvmrc )
+ else
+ cd() {
+ builtin cd "$@"
+ __rvm_project_rvmrc
+ }
+ fi
+ else
+ cd() {
+ builtin cd "$@"
+ __rvm_project_rvmrc
+ }
+ fi
fi