Open gt299792 opened 5 years ago
afaik you should be able to set this via CLI flag:
ptpython --config-dir=path/to/dir
If I don't want use flag, I want to use config file automatically. Is there any way to setup the default config path?
The default config file location is at os.path.expanduser("~/.ptpython/config.py")
.
For me on Windows 7 that is C:\Users\USERNAME\.ptpython\config.py
Covered in pull request #324
In case someone else comes looking, on Windows you can put the config.py in %LOCALAPPDATA%\prompt_toolkit\ptpython\
folder.
I found this location because ptpython kept complaining that my history file was still in %USERPROFILE%\.ptpython\history
rather than the new location %LOCALAPPDATA%\prompt_toolkit\ptpython\history
.
On windows you can set the default config also by adding to the environment variables a variable named "PYTHONSTARTUP" with the path to the file with the following code:
import sys
def configure(repl):
"""
Configuration method. This is called during the start-up of ptpython.
:param repl: `PythonRepl` instance.
"""
# Show function signature (bool).
repl.show_signature = True
# Show docstring (bool).
repl.show_docstring = True
# Fuzzy and dictionary completion.
repl.enable_fuzzy_completion = True
# Enable auto suggestions. (Pressing right arrow will complete the input,
# based on the history.)
repl.enable_auto_suggest = True
try:
from ptpython.repl import embed
except ImportError:
print("ptpython is not available: falling back to standard prompt")
else:
sys.exit(embed(globals(), locals(), configure=configure))
This will make ptpython your default Python REPL along with your custom setting. Follow this link for instructions on how to set up PYTHONPATH: https://stackoverflow.com/questions/4208659/when-to-use-sys-path-append-and-when-modifying-pythonpath-is-enough/4209102#4209102
In case someone else comes looking, on Windows you can put the config.py in
%LOCALAPPDATA%\prompt_toolkit\ptpython\
folder.I found this location because ptpython kept complaining that my history file was still in
%USERPROFILE%\.ptpython\history
rather than the new location%LOCALAPPDATA%\prompt_toolkit\ptpython\history
.
λ ptpython
Warning:
~/.ptpython/config.py
is deprecated, move your configuration to C:\Users\decak\AppData\Local\prompt_toolkit\ptpython\config.py
In Linux, It can create a ~/.ptpython/config.py file to customize the configuration. But, I use ptpython in windows, where can I create this file.