Skip to content

Instantly share code, notes, and snippets.

@stephenroller
Created February 26, 2009 22:53
Show Gist options
  • Save stephenroller/71179 to your computer and use it in GitHub Desktop.
Save stephenroller/71179 to your computer and use it in GitHub Desktop.
import readline
def make_hook(text):
def _hook():
readline.insert_text(text)
readline.redisplay()
return _hook
readline.set_pre_input_hook(make_hook(''))
while True:
line = raw_input('> ')
if line == "quit":
break
readline.set_pre_input_hook(make_hook(line))
print "you entered '%s'" % line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment