[ANN] Tab Completition for Ruby

B

Brian Schroeder

I hope, that I have not reinvented the wheel once again, but I just found
a neat way to make ri behave better. I use a short script to make bash
complete class, method and module names when pressing tab.
$ ri Array#f<TAB>
I thought there might be some people interested in this. If it is already
common knowledge, I apologize for polluting this newsgroup.

Here is the neccesary code:
___/etc/bash_completition.d/ri___
# Debian GNU/Linux ri completion
# Copyright 2004 Brian Schröder <[email protected]>
# 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}") )
fi

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

## based on:
## Debian GNU/Linux pon/poff(1) completion
## Copyright 2002 Baruch Even <[email protected]>
## License: GNU GPL v2 or later
___EOF___

more information at:
http://ruby.brian-schroeder.de/programmable_completition.html

regards,

Brian Schröder
 
Z

zuzu

I hope, that I have not reinvented the wheel once again, but I just found
a neat way to make ri behave better. I use a short script to make bash
complete class, method and module names when pressing tab.
$ ri Array#f<TAB>
I thought there might be some people interested in this. If it is already
common knowledge, I apologize for polluting this newsgroup.

Here is the neccesary code:
___/etc/bash_completition.d/ri___
# Debian GNU/Linux ri completion
# Copyright 2004 Brian Schröder <[email protected]>
# 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}") )
fi

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

## based on:
## Debian GNU/Linux pon/poff(1) completion
## Copyright 2002 Baruch Even <[email protected]>
## License: GNU GPL v2 or later
___EOF___

more information at:
http://ruby.brian-schroeder.de/programmable_completition.html

regards,

Brian Schröder


hotness. i'm especially a fan of
http://whytheluckystiff.net/clog/ruby/tabCompletionInIRb.html

peace,
-z
 
B

Brian Schroeder

If someone is interested in it, I've made a better regexp for tab
completition. If you replace

- COMPREPLY=( $(ri -l | grep "^${cur}") )
+ COMPREPLY=( $(ri -l | grep "^${cur}\|#${cur}\|::${cur}|.${cur}") )

you get also completition on
$ ri has<TAB>
Array#hash Complex#hash ...

Have fun,

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top