From: George Ogata Date: 2007-03-03T21:33:02+09:00 Subject: Re: [ANN] Bash completion for the gem command On 2/24/07, Michael Schuerig wrote: > > To my surprise there apparently hasn't been support for bash command > line completion for the gem command. I've cobbled together a file that > add just that. See > > http://schuerig.de/michael/blog/index.php/2007/02/24/gem-bash-completion/ > > I've only tested it on Debian/Linux, on other Linux/Unix variants things > might work somewhat differently. Also, I don't even try to do > completion for gem names; doing that for remote gems would be much to > slow and I haven't looked into getting that information from the local > source_cache. > > Michael Hi Michael, Thanks for the script. I've had a go at hacking in gem name completion for install and uninstall. For uninstall it uses installed names, for install it uses the names in the source cache. Only tested with gem 0.9.1. Regards, George. ---------------------------------------------------------------------- # Michael Schuerig, michael@schuerig.de, 2007-02-24 # George Ogata, george.ogata@gmail.com, 2007-03-01 # Free for all uses. GEM_CACHE_FILE=`ruby -rubygems -rrubygems/source_info_cache \ -e 'print Gem::SourceInfoCache.new.cache_file'` GEM_AVAILABLE_FILE=`dirname $GEM_CACHE_FILE`/source_cache_names # # Output all available gem names. # function available_gems { if [ ! -e $GEM_AVAILABLE_FILE -o \ $GEM_CACHE_FILE -nt $GEM_AVAILABLE_FILE ]; then ruby < $GEM_AVAILABLE_FILE require 'rubygems/source_info_cache_entry' text = File.read('$GEM_CACHE_FILE') names = Marshal.load(text).values.map do |entry| entry.source_index.latest_specs.keys end.flatten puts names.uniq EOF fi cat $GEM_AVAILABLE_FILE } # # Output all installed gem names. # function installed_gems { ruby <