mirror of
https://github.com/rydesun/dotfiles.git
synced 2025-12-26 22:55:00 +08:00
Update python startup: add python-rich
This commit is contained in:
parent
73de4c5983
commit
5fc145cc9f
1 changed files with 12 additions and 1 deletions
|
|
@ -1,7 +1,9 @@
|
|||
import atexit
|
||||
import os
|
||||
import readline
|
||||
from functools import partial
|
||||
|
||||
# 命令历史的记录文件
|
||||
xdg_data_home = os.getenv(
|
||||
'XDG_DATA_HOME', os.path.expanduser('~/.local/share'))
|
||||
data_dir = os.path.join(xdg_data_home, 'python')
|
||||
|
|
@ -15,5 +17,14 @@ except FileNotFoundError:
|
|||
readline.read_history_file(readline_history_file)
|
||||
|
||||
readline.set_history_length(1000000)
|
||||
|
||||
atexit.register(readline.write_history_file, readline_history_file)
|
||||
|
||||
# 让输出的数据结构和Traceback带有语法高亮
|
||||
# 需要安装python-rich
|
||||
try:
|
||||
from rich import inspect, pretty, traceback
|
||||
pretty.install()
|
||||
inspect_methods = partial(inspect, methods=True)
|
||||
traceback.install()
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue