Skip to content

Instantly share code, notes, and snippets.

@kenrap
Last active May 4, 2023 22:06
Show Gist options
  • Select an option

  • Save kenrap/14022b1634b5b36600c30ccf247fd30b to your computer and use it in GitHub Desktop.

Select an option

Save kenrap/14022b1634b5b36600c30ccf247fd30b to your computer and use it in GitHub Desktop.
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