File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff 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 ())
You can’t perform that action at this time.
0 commit comments