Last active
May 4, 2023 22:06
-
-
Save kenrap/14022b1634b5b36600c30ccf247fd30b to your computer and use it in GitHub Desktop.
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
| import readline | |
| import rlcompleter | |
| from os.path import expanduser | |
| class irlcompleter(rlcompleter.Completer): | |
| def complete(self, text, state): | |
| spaces = ' ' * 4 | |
| if not text: | |
| # Replace \t to 4 or 8 spaces if you prefer indent via spaces. | |
| return [spaces, None][state] | |
| else: | |
| return super().complete(text, state) | |
| # This line could bind to another key instead tab. | |
| readline.parse_and_bind("tab: complete") | |
| readline.set_completer(irlcompleter().complete) | |
| # I setup $PYTHON_STARTUP to `~/.python/startup.py`. | |
| # To be consistent, `~/.python_history` is moved to the following location. | |
| readline.read_history_file(expanduser("~/.python/history")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment