-
-
Save cybersiddhu/1107344 to your computer and use it in GitHub Desktop.
let local::lib + .llrc and rvm + .rvmrc live together happily next to eachother (if you load this -after- the rvm stuff!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$(type -t cd)" == "builtin" ]; then | |
local func="_perl_locallib_orig_cd() { builtin cd \"\$@\"; }" | |
else | |
local func="$(declare -f cd)" | |
local func="_perl_locallib_orig_cd${func#cd}" | |
fi | |
eval $func | |
_perl_locallib_custom_cd() { | |
local cwd=$(pwd) | |
if [[ "$HOME" != "$cwd" && -f "$cwd/.llrc" ]] ; then | |
local ll=$(cat $cwd/.llrc)-$(perl -e 'print $^V') | |
local OLD_PATH=$PERL_LOCAL_LIB_ROOT | |
eval $(perl -Mlocal::lib='--deactivate-all' 2>/dev/null) | |
eval $(perl -Mlocal::lib=$ll 2>/dev/null) | |
if [ "$?" -eq "0" ] && [ "$ll" != "$OLD_PATH" ] && [ -n "$PERL_LOCAL_LIB_ROOT" ]; then | |
echo "Setting local::lib to: $ll" | |
fi | |
else | |
if [[ -f "$HOME/.llrc" ]] ; then | |
local ll=$(cat $HOME/.llrc)-$(perl -e 'print $^V') | |
local OLD_PATH=$PERL_LOCAL_LIB_ROOT | |
eval $(perl -Mlocal::lib='--deactivate-all' 2>/dev/null) | |
eval $(perl -Mlocal::lib=$ll 2>/dev/null) | |
if [ "$?" -eq "0" ] && [ "$ll" != "$OLD_PATH" ] && [ -n "$PERL_LOCAL_LIB_ROOT" ]; then | |
echo "Setting local::lib to: $ll" | |
fi | |
fi | |
fi | |
} | |
cd() { | |
_perl_locallib_orig_cd "$@" | |
local result=$? | |
if [ "$result" -eq "0" ]; then | |
_perl_locallib_custom_cd "$@" | |
fi | |
return $result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment