From 48e59d377fc03feb1203c6a02d7e6424a533be62 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 30 Apr 2014 21:55:19 +0200 Subject: Fix #2282 (change the terminal title depending on the tab name) - change_title plugin --- plugins/change_title.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/change_title.py (limited to 'plugins/change_title.py') diff --git a/plugins/change_title.py b/plugins/change_title.py new file mode 100644 index 00000000..07759bc9 --- /dev/null +++ b/plugins/change_title.py @@ -0,0 +1,23 @@ +""" +This plugin will set the title of your terminal to the name of the current tab. + +""" +from plugin import BasePlugin +import sys + + +class Plugin(BasePlugin): + def init(self): + self.on_tab_change(0, self.core.current_tab_nb) + 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() + + def on_tab_change(self, old, new): + new_tab = self.core.get_tab_by_number(new) + sys.stdout.write("\x1b]0;{}\x07".format(new_tab.name)) + sys.stdout.flush() + -- cgit v1.2.3