Hi, Sorry for my first post, it wasn't what you not already knew. I should better read then write, but I hope on the bottom I found something that help. On 17.07.2008, at 18:44, Marc Heiler wrote: > is there a way to "find out" what a user already typed in readline? > > Reason is, i am fetching user input like so: > > > user_input = Readline.readline(' Input name of a dir, then press > <TAB>'+"\n",true) > > And with Readline.completion_proc i have code that will return only irs > in this directory. But I would like to invoke this specific code part > only > when a user typed in i.e. "cd " > > So if i have a directory called "foobar" it should work here: > > > "cd foo<TAB>" # completed to foobar > > but if the user would type > > "blabalblabla foo<TAB>" # there should be no result I tested a bit your scenario and I think you have to set Readline.completer_word_break_characters , but not to " \t\n\"\ \'`><=;|&{(" If you set it to "\t\n\"\\'`><=;|&{(", without whitespace, you will et as input in your CompletionProc the whole line. Then you can do: when /^cd/ typed = input.sub("cd","").strip ... $ tabcompletion_test.rb cd bl|cd bl| # tab called after 'cd bl' $ cat tabcompletion_test.rb require 'readline' module MYCMD ReservedWords = [ "BEGIN", "END", "yield", ] CompletionProc = proc { |input| puts("|#{input}|") case input when /^cd/ typed = input.sub("cd","") if typed=="" candidates = Dir.entries(".") elsif typed == " " candidates = Dir.entries(".") else candidates = ["no"] end else (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/) end } def self.select_message(receiver, message, candidates) candidates.grep(/^#{message}/).collect do |e| puts("e:#{e}") case e when /^[a-zA-Z_]/ receiver + "." + e end end end end ## no ' ' Readline.completer_word_break_characters= "\t\n\"\\'`><=;|&{(" Readline.completion_append_character = nil Readline.completion_proc = MYCMD::CompletionProc loop do cmd = Readline.readline eval(cmd.chomp) end regards, Sandor Szs --