Skip to content

Instantly share code, notes, and snippets.

@dnoseda
Created January 24, 2013 23:58
Show Gist options
  • Save dnoseda/4629920 to your computer and use it in GitHub Desktop.
Save dnoseda/4629920 to your computer and use it in GitHub Desktop.
# for gvm to autopick grails version only when cd in a grails proyect
alias autopick='AUTO_VERSION=`grep app.grails.version application.properties` ; AUTO_VERSION=${AUTO_VERSION:19}; gvm use grails $AUTO_VERSION'
chdir() {
local action="$1"; shift
case "$action" in
# popd needs special care not to pass empty string instead of no args
popd) [[ $# -eq 0 ]] && builtin popd || builtin popd "$*" ;;
cd)
if [ $# -eq 0 ]
then
builtin $action "$HOME" ;
else
builtin $action "$*";
fi;;
pushd) builtin $action "$*" ;;
*) return ;;
esac
# now do stuff in the new pwd
if [ -f ./application.properties ]
then
autopick
fi
}
alias cd='chdir cd'
alias pushd='chdir pushd'
alias popd='chdir popd'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment