Also call .shutdown() in ipython
This commit is contained in:
parent
b0495d028f
commit
bb63722fb1
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue