that's good stuff florian! any idea how to make this work? (it's a snippet out
of something i'm working on attm):
harp:~ > cat a.rb
require 'readline'
require 'rubygems'
require_gem 'term-ansicolor'
class ::String; include Term::ANSIColor; end
complete = lambda do |words|
words = words.strip.split(%r/\s+/) unless Array === words
Readline::completion_proc = lambda do |s|
list = words.select{|c| c.index s}
list = list.empty? ? words : list
list.map{|word| word.blue}
end
end
sif_in =
readline =
if STDIN.tty?
lambda{|prompt| line = Readline::readline(prompt.strip.red.dark.bold.underline << " ").to_s.strip; sif_in << line; line.empty? ? nil : line}
else
lambda{|prompt| line = STDIN.gets.to_s.strip; sif_in << line; line.empty? ? nil : line}
end
complete['one two three']
line = readline['number >']
puts line
the interaction between the completion_proc and term-ansicolor results in the
the escape codes being shown literally? thoughts?
You can set RUBYOPT=-rubygems in your environment, if you don't want to require 'rubygems'. So users can transparently either use gems or install from source or use their package managers.
I'm not sure that made english sense. Let's try that again.
Silly me, "a bit of time" for Ruby really is only a small bit of time.
I have some time right now so I'll play with it.
I played with it, and like everything else I've seen I'll need to
learn a bit more to get it to work. However, I quickly googled for
someone else's code and easily adapted it to my needs:
Always a catch. Ok, I'd rather insert it into my code manually every
time.. at this point I"m just goofing around anyways.
···
On 4/12/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Thu, 13 Apr 2006, Sy Ali wrote:
> On 4/12/06, Florian Frank <flori@nixe.ping.de> wrote:
>> You can set RUBYOPT=-rubygems in your environment
> <snip>
>
> Aah, good point. Maybe I should also recommend this for the guys who
> handle the packages for my Linux distro.
be careful. it's breaks some packages, like the gsl.