Created
November 5, 2009 19:13
-
-
Save brettg/227299 to your computer and use it in GitHub Desktop.
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
GEMPATHS=`gem environment | awk '/GEM PATHS/, /GEM [^P]/ {print $2}' | grep -v GEM` | |
function gemdir { | |
echo $GEMPATHS | xargs -n 1 -I %s find %s/gems -type d -depth 1 | grep $1 | sort | tail -1 | |
} | |
# really awesome function, use: cdgem <gem name>, cd's into your gems | |
# directory and opens gem that best matches the gem name provided | |
function cdgem { | |
GEMDIR=`gemdir $1` | |
if [ $GEMDIR ] && [ -d $GEMDIR ]; then | |
cd $GEMDIR | |
else | |
echo "No gem found for $1 in $GEMPATHS" | |
return 1 | |
fi | |
} | |
function mategem { | |
(cdgem $1 && mate .) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment