Skip to content

Instantly share code, notes, and snippets.

@da-ar
Created November 22, 2013 16:45
Show Gist options
  • Save da-ar/7603015 to your computer and use it in GitHub Desktop.
Save da-ar/7603015 to your computer and use it in GitHub Desktop.
Bash style user prompt
import readline, glob, os
class ControllerDeploy:
def __init__(self):
print "Starting Deploy Script"
readline.set_completer_delims(" \n\t;")
readline.set_completer(complete)
readline.parse_and_bind("tab: complete")
while 1:
a = raw_input("> ")
print "You entered", a
def complete(val, state):
if(val[0] == "~"):
val = os.path.expanduser(val)
return (glob.glob(val+'*')+[None])[state]
if __name__ == "__main__":
main = ControllerDeploy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment