# Gem Doc export GEMDIR=`gem env gemdir` gemdoc() { open $GEMDIR/doc/`$(which ls) $GEMDIR/doc | grep $1 | sort | tail -1`/rdoc/index.html } _gemdocomplete() { COMPREPLY=($(compgen -W '$(`which ls` $GEMDIR/doc)' -- ${COMP_WORDS[COMP_CWORD]})) return 0 } complete -o default -o nospace -F _gemdocomplete gemdoc