From 14d0391e702a60a7fad6b6b3433d47fbe742b8c5 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Sat, 2 Mar 2013 03:22:10 -0300 Subject: [PATCH] setup rvm based on PWD variable --- plugins/rvm/cd.fish | 34 ---------------------------------- plugins/rvm/rvm.load | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 34 deletions(-) delete mode 100644 plugins/rvm/cd.fish create mode 100644 plugins/rvm/rvm.load diff --git a/plugins/rvm/cd.fish b/plugins/rvm/cd.fish deleted file mode 100644 index 86d62c4..0000000 --- a/plugins/rvm/cd.fish +++ /dev/null @@ -1,34 +0,0 @@ -# -# Source a .rvmrc file in a directory after changing to it, if it exists. -# To disable this feature, set rvm_project_rvmrc=0 in $HOME/.rvmrc -# -function cd --description "Change directory" - redefine_function 'cd' "$__fish_datadir/functions/cd.fish" ' - function cd --description "Change working directory" - old_cd "$argv" - - if test "$rvm_project_rvmrc" != 0 - set -l cwd $PWD - while true - if contains $cwd "" $HOME "/" - if test "$rvm_project_rvmrc_default" = 1 - rvm default 1>/dev/null 2>&1 - end - break - else - if begin ; test -s ".rvmrc" ; or test -s ".versions.conf" ; end - rvm reload 1>/dev/null 2>&1 - break - else - set cwd (dirname "$cwd") - end - end - end - - set -e cwd - end - end -' - - cd "$argv" -end diff --git a/plugins/rvm/rvm.load b/plugins/rvm/rvm.load new file mode 100644 index 0000000..ae50174 --- /dev/null +++ b/plugins/rvm/rvm.load @@ -0,0 +1,24 @@ +function __check_rvm --on-variable PWD --description 'Setup rvm on directory change' + status --is-command-substitution; and return + + if test "$rvm_project_rvmrc" != 0 + set -l cwd $PWD + while true + if contains $cwd "" $HOME "/" + if test "$rvm_project_rvmrc_default" = 1 + rvm default 1>/dev/null 2>&1 + end + break + else + if begin ; test -s ".rvmrc" ; or test -s ".versions.conf" ; end + rvm reload 1>/dev/null 2>&1 + break + else + set cwd (dirname "$cwd") + end + end + end + + set -e cwd + end +end