Created
January 10, 2013 21:13
-
-
Save skinp/4505849 to your computer and use it in GitHub Desktop.
Primitive file completion in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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