From: "Sandor Szücs" Date: 2008-07-19T04:57:19+09:00 Subject: Re: Readline and conditional tab results based on input I should be even more specific. On 18.07.2008, at 21:15, Sandor Szücs wrote: >> "cd foo" # completed to foobar >> >> but if the user would type >> >> "blabalblabla foo" # there should be no result ~~~~~~~~~~~~~~~~~~~~~ require 'readline' module MYCMD CompletionProc = proc { |input| case input when /^cd/ typed = input.sub("cd","") typed.strip! save = input.sub(/#{typed}\z/,"") fragment = File.basename(typed) tmp = Dir.entries(File.dirname(typed)) candidates = tmp.select {|f| f.match(/^#{Regexp.quote(fragment)}/)} candidates.map! {|f| save+File.dirname(typed)+"/"+f+"/"} end } #Readline.completer_word_break_characters= "\t\n\"\\'`><=;|&{(" Readline.completer_word_break_characters= "\t" Readline.completion_append_character = nil Readline.completion_proc = MYCMD::CompletionProc loop do cmd = Readline.readline eval(cmd.chomp) end ~~~~~~~~~~~~~~~~~~~~~ That was what you have expected, or? regards, Sandor Szücs --