2014-04-30 19:55:19 +00:00
|
|
|
"""
|
|
|
|
This plugin will set the title of your terminal to the name of the current tab.
|
|
|
|
|
|
|
|
"""
|
2016-06-27 23:10:52 +00:00
|
|
|
from poezio.plugin import BasePlugin
|
2014-04-30 19:55:19 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
class Plugin(BasePlugin):
|
|
|
|
def init(self):
|
2018-07-22 14:17:06 +00:00
|
|
|
self.on_tab_change(None, new_tab=self.core.tabs.current_tab)
|
2014-04-30 19:55:19 +00:00
|
|
|
self.api.add_event_handler('tab_change', self.on_tab_change)
|
|
|
|
|
|
|
|
def cleanup(self):
|
|
|
|
"Re-set the terminal title to 'poezio'"
|
|
|
|
sys.stdout.write("\x1b]0;poezio\x07")
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
2018-07-22 14:17:06 +00:00
|
|
|
def on_tab_change(self, old_tab, new_tab):
|
2014-04-30 19:55:19 +00:00
|
|
|
sys.stdout.write("\x1b]0;{}\x07".format(new_tab.name))
|
|
|
|
sys.stdout.flush()
|