diff --git a/powerline/bindings/ipython/post_0_11.py b/powerline/bindings/ipython/post_0_11.py index c0c40ce1..e8a685a6 100644 --- a/powerline/bindings/ipython/post_0_11.py +++ b/powerline/bindings/ipython/post_0_11.py @@ -2,6 +2,7 @@ from powerline.ipython import IpythonPowerline from IPython.core.prompts import PromptManager +from IPython.core.hooks import TryNext class PowerlinePromptManager(PromptManager): @@ -41,6 +42,12 @@ def load_ipython_extension(ip): ip.prompt_manager = PowerlinePromptManager(powerline=powerline, shell=ip.prompt_manager.shell, config=ip.prompt_manager.config) + def shutdown_hook(): + powerline.renderer.shutdown() + raise TryNext() + + ip.hooks.shutdown_hook.add(shutdown_hook) + def unload_ipython_extension(ip): ip.prompt_manager = old_prompt_manager diff --git a/powerline/bindings/ipython/pre_0_11.py b/powerline/bindings/ipython/pre_0_11.py index 098ddb6b..b83780d4 100644 --- a/powerline/bindings/ipython/pre_0_11.py +++ b/powerline/bindings/ipython/pre_0_11.py @@ -2,6 +2,7 @@ from powerline.ipython import IpythonPowerline from IPython.Prompts import BasePrompt from IPython.ipapi import get as get_ipython +from IPython.ipapi import TryNext class PowerlinePrompt(BasePrompt): @@ -38,4 +39,11 @@ def setup(prompt='1', **kwargs): old_prompt = getattr(ip.IP.outputcache, attr) setattr(ip.IP.outputcache, attr, PowerlinePrompt(powerline, old_prompt.cache, old_prompt.sep, '', old_prompt.pad_left)) + raise TryNext() + + def shutdown_hook(): + powerline.renderer.shutdown() + raise TryNext() + ip.IP.hooks.late_startup_hook.add(late_startup_hook) + ip.IP.hooks.shutdown_hook.add(shutdown_hook)