Skip to content

Instantly share code, notes, and snippets.

@ahx
Created October 6, 2009 15:29
Show Gist options
  • Save ahx/203121 to your computer and use it in GitHub Desktop.
Save ahx/203121 to your computer and use it in GitHub Desktop.
# geme (aka mategem, vigem..) - open gem source in $EDITOR
geme() {
_geme_init_gemdir
$EDITOR $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep -x $1.* | sort | tail -1`/
}
_geme() {
_geme_init_gemdir
COMPREPLY=()
local curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '$(ls $GEMDIR/gems)' -- $curw));
return 0
}
_geme_init_gemdir() {
# This function is here, because dont want to wait for 'gem env gemdir'
# each time i open a new Terminal window.
if [[ $GEMDIR ]]; then
return
else
export GEMDIR=`gem env gemdir`
fi
}
complete -F _geme -o dirnames geme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment