Created
December 9, 2010 19:34
-
-
Save metavida/735200 to your computer and use it in GitHub Desktop.
The portion of my .bash_login doc that sets up gemdoc and gem open
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
# gemdoc via http://stephencelis.com/archive/2008/6/bashfully-yours-gem-shortcuts | |
# needs to happen | |
gemdoc() { | |
open $GEM_HOME/doc/`$(which ls) $GEM_HOME/doc | grep $1 | sort | tail -1`/rdoc/index.html | |
} | |
_completegemlist() { | |
local cmd=${COMP_WORDS[0]} | |
local subcmd=${COMP_WORDS[1]} | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
if [[ "$cmd" == "gemdoc" ]] ; then subcmd="doc" ; fi | |
case "$subcmd" in | |
open | doc) | |
words=`ruby -rubygems -e 'puts Dir["{#{Gem::SourceIndex.installed_spec_directories.join(",")}}/*.gemspec"].collect {|s| File.basename(s).gsub(/\.gemspec$/, "")}'` | |
;; | |
*) | |
return | |
;; | |
esac | |
COMPREPLY=($(compgen -W "$words" -- $cur)) | |
return 0 | |
} | |
complete -o default -o nospace -F _completegemlist gemdoc | |
complete -o default -F _completegemlist gem | |
# end gemdoc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment