From a80598582d0489afea705a936a40121e6b40e1c5 Mon Sep 17 00:00:00 2001 From: Mario Fernandez Date: Sun, 15 Jan 2012 16:15:28 +0100 Subject: [PATCH] Add helper method to cd directly to the directory where a gem's source code is located --- plugins/rvm/rvm.plugin.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 604c00713..4e550614b 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -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) +}