Skip to content

Instantly share code, notes, and snippets.

@skinp
Created January 10, 2013 21:13
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 skinp/4505849 to your computer and use it in GitHub Desktop.
Save skinp/4505849 to your computer and use it in GitHub Desktop.
Primitive file completion in python
#!/usr/bin/env python
import readline
import glob
def complete(text, state):
for file in glob.glob(text+"*"):
if not state:
return file
else:
state -= 1
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)
raw_input('Filename: ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment