From 995f4b27a84d5b0faf0c64a8bccaa443f95835b7 2014-11-11 04:10:51 From: Jason Newton Date: 2014-11-11 04:10:51 Subject: [PATCH] save and restore ps1/ps2 --- diff --git a/IPython/terminal/embed.py b/IPython/terminal/embed.py index 550a108..b2f3408 100644 --- a/IPython/terminal/embed.py +++ b/IPython/terminal/embed.py @@ -251,6 +251,14 @@ def embed(**kwargs): config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell kwargs['config'] = config + #save ps1/ps2 if defined + ps1 = None + ps2 = None + try: + ps1 = sys.ps1 + ps2 = sys.ps2 + except AttributeError: + pass #save previous instance saved_shell_instance = InteractiveShell._instance if saved_shell_instance is not None: @@ -265,3 +273,6 @@ def embed(**kwargs): cls.clear_instance() for subclass in cls._walk_mro(): subclass._instance = saved_shell_instance + if ps1 is not None: + sys.ps1 = ps1 + sys.ps2 = ps2