summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-30 21:55:19 +0200
committermathieui <mathieui@mathieui.net>2014-04-30 21:55:19 +0200
commit48e59d377fc03feb1203c6a02d7e6424a533be62 (patch)
tree9761244bdb2539b6d704136d6a9aa7c560bb4854
parentc1d19fa5486da8706b73785fc5350139867493b0 (diff)
downloadpoezio-48e59d377fc03feb1203c6a02d7e6424a533be62.tar.gz
poezio-48e59d377fc03feb1203c6a02d7e6424a533be62.tar.bz2
poezio-48e59d377fc03feb1203c6a02d7e6424a533be62.tar.xz
poezio-48e59d377fc03feb1203c6a02d7e6424a533be62.zip
Fix #2282 (change the terminal title depending on the tab name)
- change_title plugin
-rw-r--r--doc/source/plugins/change_title.rst6
-rw-r--r--doc/source/plugins/index.rst6
-rw-r--r--plugins/change_title.py23
3 files changed, 35 insertions, 0 deletions
diff --git a/doc/source/plugins/change_title.rst b/doc/source/plugins/change_title.rst
new file mode 100644
index 00000000..9a669a80
--- /dev/null
+++ b/doc/source/plugins/change_title.rst
@@ -0,0 +1,6 @@
+.. _changetitle-plugin:
+
+Title change
+============
+
+.. automodule:: change_title
diff --git a/doc/source/plugins/index.rst b/doc/source/plugins/index.rst
index d608742f..452c2e8a 100644
--- a/doc/source/plugins/index.rst
+++ b/doc/source/plugins/index.rst
@@ -235,6 +235,11 @@ Plugin index
Manage IRC gateways with biboumi more easily
+ Title change
+ :ref:`Documentation <changetitle-plugin>`
+
+ Change the title of the terminal according to the name
+ of the current tab.
.. toctree::
@@ -273,3 +278,4 @@ Plugin index
pointpoint
autocorrect
irc
+ change_title
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()
+