Skip to content

Instantly share code, notes, and snippets.

@abachman
Created March 20, 2009 14:43
Show Gist options
  • Save abachman/82386 to your computer and use it in GitHub Desktop.
Save abachman/82386 to your computer and use it in GitHub Desktop.
# drop in your ~/.bashrc file. guaranteed to "works on my machine".
#
# Go straight to the root of the current rails project.
# example:
# ~/workspace/proj/app/models $ rr
# going to /home/user/workspace/proj
# ~/workspace/proj $
#
# /etc/init.d/ $ rr
# /etc/init.d/ $
rr() {
CURRENT_PWD=`pwd`
FAILED_RR=0
# Drop down the path until we hit a directory containing
# "app" "config" "log" and "test"
until [[ "$(ls)" =~ ^app.*config.*log.*test ]]; do
cd ..
if [ $(pwd) = / ]; then
FAILED_RR=1
break
fi
done
if [ $FAILED_RR -eq 1 ]; then
cd $CURRENT_PWD
else
echo "going to `pwd`"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment