Bash Completion for the gem Command
February 24th, 2007 by michael
The gem command is the command line user interface to the RubyGems system for managing Ruby packages.
This command has a few sub-commands itself and a long list of options that differ per sub-command. Remembering and typing them can be tedious, but thankfully, if you are using the bash command shell, it can help with this task. It only has to be told how.
I’ve packaged the how in this file. Copy it to /etc/bash_completion.d and hope that your bash installation picks it up the next time you start a shell.
On Debian/Linux system that’s just how it works. If this does not work on your particular version of Linux or Unix, you’ll have to look up how completions are handled on your system.

Thank you for the very handy function!
This is exactly what I was looking for…
But I’m afraid you’ve missed one line in that file:
have gem &&
_gem()
{
#…
With best regards,
Chepel
Chepel, thanks for pointing this out. I’ve changed the completion file accordingly.
I hope you guys don’t mind; I’ve added gem name completion, updated for v1.1.1, and put up on github. Full credits left intact of course.
http://github.com/george-ogata/ruby-bash-completion
Thanks for your efforts!
I don’t seem to have a ‘have’ command
-bash: have: command not found
Where can I get it?
Nic: the function
haveought to be defined in /etc/bash_completion. I don’t know what you need to install on your system to get that file, on Debian/Linux it is part of the bash_completion package.Anyway,
haveis defined like thishave() { unset -v have PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && have="yes" }Awesome, working a treat now.
Hi!
I want to extend my SQL experience.
I red so many SQL books and want to
read more about SQL for my work as db2 database manager.
What can you recommend?
Thanks,
Werutz
Werutz, somehow your question doesn’t fit in very well in this place. Also, if you’ve read many SQL books already, it is hard for me to suggest any more without knowing what you already know.
Anyway, here are a few
I was seeing errors like:
No such file or directory – ~/.gem/latest_source_cache (Errno::ENOENT)
cat: ~/.gem/all_names.completion: No such file or directory
Just did a “touch ~/.gem/all_names.completion” to create the dummy file and now everything working nicely (commands and all their args!); not sure why. Thank you for the highly valuable completion!!
I’m noticing now that this completion is included in Ubuntu Lucid Lynx, as part of rubygems1.8 (and surely 1.9). Cool. Unfortunately, it only works if you invoke as `gem1.8`, not just: `gem `