A ruby a day!

ri Programmable Completition

ri programmable completition at work

If you use bash, you can make ri more intelligent. Imagine typing

$ ri Array#f<tab>

and having bash responding with

Array#fetch     Array#fill      Array#first     Array#flatten   Array#flatten!  Array#frozen?

this is possible.

Just enable programmable completition for ri by sourcing in the following file:

# Debian GNU/Linux ri completion
# Copyright 2004 Brian Schröder 
# License: GNU GPL v2 or later

have ri &&
_ri()
{
    local cur conns

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}

    if [ $COMP_CWORD -eq 1 ]; then
        COMPREPLY=( $(ri -l |  grep "^${cur}\|#${cur}\|::${cur}|.${cur}") )
    fi

    return 0
}
[ "$have" ] && complete -F _ri ri

## based on:
## Debian GNU/Linux pon/poff(1) completion
## Copyright 2002 Baruch Even 
## License: GNU GPL v2 or later

Under Debian the easiest way to achieve this is putting the source above into a file /etc/bash_completition.d/rpa

You may download this file here rpa completition.

Good luck,

Brian