public
Description: Command-line completion for Ruby-related commands under Bash: rake, gem, rails, ruby, jruby
Homepage:
Clone URL: git://github.com/mernen/completion-ruby.git
mernen (author)
Sun Jun 07 22:48:43 -0700 2009
commit  6f99f4f3882d2b3e78f6d8168ba0e1e26d4f99c2
tree    5882ea0f72ba1f149afa88bd3691417b0fa93a58
parent  c4225bb7f1fcd47a2c3cf3cb5ac38aaf514181a5
name age message
file MIT-LICENSE Sun Jul 27 17:14:13 -0700 2008 Added license file. [mernen]
file README.markdown Loading commit data...
file completion-gem
file completion-jruby
file completion-rails Sat Jan 24 15:06:17 -0800 2009 More stylistic, no-op changes. [mernen]
file completion-rake Sat Jan 24 15:06:17 -0800 2009 More stylistic, no-op changes. [mernen]
file completion-ruby Sat Jan 24 15:06:17 -0800 2009 More stylistic, no-op changes. [mernen]
file completion-ruby-all
README.markdown

completion-ruby: bash completion for Ruby-related commands

completion-ruby is a set of bash scripts offering command-line completion for various Ruby-related commands and tools.

Usage

Save the completion files somewhere (in the same directory) and add the following line to your ~/.bashrc or ~/.profile:

. /path/to/completion-ruby-all

The completion-ruby-all script loads all the completions it finds, but only for the commands you appear to have installed. Alternatively, you can just save the specific scripts you wish, and source them individually.

These scripts have a slight dependency on bash-completion. It should be part of pretty much any modern Linux distribution, and you can install it on OS X using MacPorts:

sudo port install bash-completion

This script is a dependency of Git's completion too, so if you have that working already you should be fine.

Why yet another completion script?

Before writing my own, I'd seen about five different scripts for rake completion. None of them, though, at the same time:

  • cached the task list for fast results;
  • invalidated said cache when the rakefile was modified;
  • worked properly with namespaces; and
  • worked on subdirectories of the project

...among other minor quirks. While providing all of the above, a few other niceties were added, like command-line options completion and awareness of task arguments.

This script is not perfect (for instance, it won't update the cache if a dependency of the rakefile is updated; as a workaround, simply touch the Rakefile), but it tries to cover all the most common cases without overcomplicating or overthinking the code.

License and website

Copyright (C) 2008 Daniel Luz.

completion-ruby is distributed under the MIT license.

The source is available in a Git repository, available at GitHub.

For up-to-date information, visit this project's permalink.