I am having a hard time understanding readline. If i have a list of
possible matches for given files (and subdirectories) in a directory,
how can I make readline work with that, so that i can type something
like:
some_method r<TAB>
where some_method would be just a method, and "r" a file in current
directory (ie. rx.rb ry.rb rz.rb files)
Readline.completion_proc = proc do |word|
Dir['*'].grep(/\A#{Regexp.quote(word)}/)
end
Readline.completion_case_fold = true
# hmm
I am having a hard time understanding readline. If i have a list of
possible matches for given files (and subdirectories) in a directory,
how can I make readline work with that, so that i can type something
like:
some_method r<TAB>
where some_method would be just a method, and "r" a file in current
directory (ie. rx.rb ry.rb rz.rb files)
Readline.completion_proc = proc do |word|
Dir['*'].grep(/\A#{Regexp.quote(word)}/)
end
Readline.completion_case_fold = true
This actually already works on JRuby by mistake; something to do with the readline library we use. It's a bug, but it's rather amusing:
I am having a hard time understanding readline. If i have a list of
possible matches for given files (and subdirectories) in a directory,
how can I make readline work with that, so that i can type something
like:
some_method r<TAB>
where some_method would be just a method, and "r" a file in current
directory (ie. rx.rb ry.rb rz.rb files)
Readline.completion_proc = proc do |word|
Dir['*'].grep(/\A#{Regexp.quote(word)}/)
end
Readline.completion_case_fold = true
# hmm
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama
Hmm but how does it work?
Guess i have to look at the source
Considering that it's a bug...I'm not really sure
I believe it has something to do with our readline library (Jline) probably having some default mode where tab completion includes the current directory.