-
-
Save ganta/4689233 to your computer and use it in GitHub Desktop.
Modified to follow symbolic links.
This file contains hidden or 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
__gvm_switch() { | |
if [ -s "application.properties" ]; then | |
local arr candidate candidate_home current target | |
arr=($(cat application.properties | grep --color=never 'app.\(grails\|griffon\).version' | sed "s_app.\(.*\).version=\(.*\)_\1 \2_g")) | |
candidate=${arr[1]} | |
target=${arr[2]} | |
candidate_home=$(eval echo '$'$(echo $candidate | tr '[:lower:]' '[:upper:]')_HOME) | |
if [ ! -z "$(readlink $candidate_home)" ]; then | |
candidate_home=$(readlink $candidate_home) | |
fi | |
current=$(echo $candidate_home | sed -e "s_$GVM_DIR/$candidate/__g") | |
if [[ $current != $target ]]; then | |
echo "Switching to $candidate $target ..." | |
gvm use $candidate $target | |
fi | |
fi | |
} | |
chpwd() { | |
__gvm_switch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment