Hi!

I hacked irb/completion.rb such that now it does filename completion (not
just ruby expression completion). (A word is completed as a filename if it
begins with ./, ../, /, or ~/ .) I think this feature is close to being
essential for those who tend using irb as a better shell (like me)...

Where can I submit it "officially" as patch?

It would be stupid to keep you from using it 'till the above question gets
answered, so here it is (don't be frightened from the 1.9 in the path of the
source file, irb/completion.rb hasn't changed for ages).

<patch>
--- /usr/lib/ruby/1.9/irb/completion.rb 2004-11-29 00:58:22.000000000 -0700
+++ /home/csaba/ruby/irb-completion-hacked.rb   2005-01-13
21:47:55.623699056 -0700
@@ -34,12 +34,36 @@
       "yield",
     ]
       
+    FS = File::SEPARATOR
+
+    def self.filecomp(input)
+        fsq = Regexp.quote FS    
+        input =~ Regexp.new("(.*)#{fsq}([^#{fsq}]*)$")
+        d, f = $1, $2
+        d.empty? and d = FS
+        d[0] == ?~ and d = File.expand_path(d)
+        can =
+        begin
+          Dir.entries(d).select{|e| e.index(f) == 0 }.map { |e|
+           de=File.join(d,e)
+           de + (File.directory?(de) ? FS : "") 
+         }
+        rescue => err
+          warn "Error while doing filename completion: #{err}"
+        end
+        can || []
+    end
+
+
     CompletionProc = proc { |input|
       bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
       
 #      puts "input: #{input}"
 
       case input
+      when Regexp.new("^(?:|\.|\.\.|~.*)" + FS)
+        # Smells like a filename
+        filecomp input
       when /^(\/[^\/]*\/)\.([^.]*)$/
        # Regexp
        receiver = $1
</patch>