Add helper method to cd directly to the directory where a gem's source code is located

This commit is contained in:
Mario Fernandez 2012-01-15 16:15:28 +01:00
commit a80598582d

View file

@ -42,3 +42,12 @@ function gems {
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
}
# Go to the directory where the given gem is defined.
#
# Credit to: https://github.com/henrik/dotfiles/blob/master/bash/functions.sh
function cdgem {
local target=${1?No name for a gem given}
local gemdir=`rvm gemdir`
cd ${gemdir}/gems; cd $(find . -maxdepth 1 -name "*${target}*" | sort | tail -1)
}