jweslley / rails_completion

Bash completion support for Ruby on Rails.
Other
105 stars 16 forks source link

Completion does not work for second-level arguments #3

Closed zaki closed 13 years ago

zaki commented 13 years ago

Completion works for "first level" commands (console, generate, server etc). However for further parameters, it stops working.

$ rails g<TAB><TAB>
g         generate
$ rails  generate <TAB><TAB>
benchmarker  db           g            profiler     server
c            dbconsole    generate     runner       
console      destroy      plugin       s

Environment: Mac OSX 10.6.7, bash, rails 3.0.6, ruby 1.9.2-p180 through RVM, gem 1.5.0

jweslley commented 13 years ago

On the first time, the generate command takes a some while to show the options. This delay occurs because the completion script inspect your rails application looking for generators which are cached into .rails_generators file.

zaki commented 13 years ago

No, it wasn't generating the cache file, but I think I figured out what the problem was for me. Completion works if I change the sed command in __railscmd() to look like this:

any_command=$(echo $2 | sed -e 's/[[:space:]]/|/g')

For some reason it looks like sed does not understand the whitespace marker \s although I'm not really sure yet why that is.