Skip to content

Instantly share code, notes, and snippets.

@no6v
Created May 1, 2011 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save no6v/950671 to your computer and use it in GitHub Desktop.
Save no6v/950671 to your computer and use it in GitHub Desktop.
module Earthquake::Input
def friends
@friends ||= []
end
end
Earthquake.init do
output :friend_completion do |item|
next unless item["user"]
(friends << "@#{item["user"]["screen_name"]}").uniq!
end
input_filter do |text|
text.scan(/@[0-9A-Za-z_]+/) do |screen_name|
(friends << screen_name).uniq!
end
end
Readline.basic_word_break_characters = Readline.basic_word_break_characters.delete("@")
completion_proc = Readline.completion_proc
Readline.completion_proc = lambda do |text|
case text
when /^@/
friends.grep(/^#{text}/)
else
completion_proc.call(text)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment