Skip to content

Commit b436e79

Browse files
roee30jonathanslenders
authored andcommitted
Feature: read ipython config files
1 parent 321d9e1 commit b436e79

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ptpython/ipython.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,21 @@ def embed(**kwargs):
282282
kwargs["config"] = config
283283
shell = InteractiveShellEmbed.instance(**kwargs)
284284
initialize_extensions(shell, config["InteractiveShellApp"]["extensions"])
285+
run_startup_scripts(shell)
285286
shell(header=header, stack_depth=2, compile_flags=compile_flags)
287+
288+
289+
def run_startup_scripts(shell):
290+
"""
291+
Contributed by linyuxu:
292+
https://github.com/prompt-toolkit/ptpython/issues/126#issue-161242480
293+
"""
294+
import glob
295+
import os
296+
297+
startup_dir = shell.profile_dir.startup_dir
298+
startup_files = []
299+
startup_files += glob.glob(os.path.join(startup_dir, "*.py"))
300+
startup_files += glob.glob(os.path.join(startup_dir, "*.ipy"))
301+
for file in startup_files:
302+
shell.run_cell(open(file).read())

0 commit comments

Comments
 (0)