import sys import select import tty import termios import os import readline addrs = ['a@a.com', 'digger@pansen.com'] def mytool(): print 'MT' def completer(text, state): options = [x for x in addrs if x.startswith(text)] try: return options[state] except IndexError: return None #readline.set_completer(completer) readline.parse_and_bind('tab:complete') while True: a = raw_input('$ ') print a """ #print "#> ", os.system("stty cbreak -echo") cmdstring = '' while True: #print '---' a = sys.stdin.read(1) #sys.stdout.write(a) sys.stdout.write('\r') if a == '\n': #print 'ENTER' a = '' cmdstring = '' print 's' sys.stdout.write('\r') elif a == '\010': print 'ENTER' a = '' sys.stdout.write('\r') else: cmdstring = cmdstring + a sys.stdout.write('$ ' + cmdstring) sys.stdout.flush() os.system("stty -cbreak echo") """ """ fd = sys.stdin.fileno() old = termios.tcgetattr(fd) tty.setcbreak(fd) ch = sys.stdin.read(1) print "Read", ch termios.tcsetattr(fd, termios.TCSADRAIN, old) """