File: change_title.py

package info (click to toggle)
poezio 0.16-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,124 kB
  • sloc: python: 25,093; xml: 995; ansic: 329; makefile: 200; sh: 74; javascript: 2
file content (21 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
This plugin will set the title of your terminal to the name of the current tab.

"""
from poezio.plugin import BasePlugin
import sys


class Plugin(BasePlugin):
    def init(self):
        self.on_tab_change(None, new_tab=self.core.tabs.current_tab)
        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_tab, new_tab):
        sys.stdout.write("\x1b]0;{}\x07".format(new_tab.name))
        sys.stdout.flush()