summaryrefslogtreecommitdiff
path: root/.config/python/startup.py
blob: ef803546ac50d657a7201b8c66965a5e68e4686b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import atexit
import os
import sys
from pathlib import Path
import readline


try:
	readline.parse_and_bind("tab: complete")
except ImportError:
	pass


if hasattr(sys, '__interactivehook__'):
	del sys.__interactivehook__


histfile = Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "python_history"
try:
	histfile.touch(exist_ok=True)
except FileNotFoundError:
	histfile.parent.mkdir(parents=True, exist_ok=True)

readline.read_history_file(histfile)
readline.set_history_length(5_000)
atexit.register(readline.write_history_file, histfile)