From 85a3da057f25c785ed6d8ae3d5eac3093709e82b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 8 Jan 2018 12:47:47 +0530 Subject: [PATCH] Session file: Allow setting the title for windows --- README.asciidoc | 2 ++ kitty/session.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index c8026d077..7398d8246 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -291,6 +291,8 @@ cd ~ # Create a window and run the specified command in it launch zsh launch vim +# Set the title for the next window +title Chat with x launch irssi --profile x # Create a new tab (the part after new_tab is the optional tab name which will diff --git a/kitty/session.py b/kitty/session.py index b35fbe80e..6685d2fb3 100644 --- a/kitty/session.py +++ b/kitty/session.py @@ -18,6 +18,7 @@ class Tab: self.enabled_layouts = opts.enabled_layouts self.layout = (self.enabled_layouts or ['tall'])[0] self.cwd = None + self.next_title = None class Session: @@ -31,6 +32,9 @@ class Session: del self.tabs[-1] self.tabs.append(Tab(opts, name)) + def set_next_title(self, title): + self.tabs[-1].next_title = title.strip() + def set_layout(self, val): if val not in all_layouts: raise ValueError('{} is not a valid layout'.format(val)) @@ -42,7 +46,9 @@ class Session: else: cmd = None from .tabs import SpecialWindow - self.tabs[-1].windows.append(SpecialWindow(cmd, cwd=self.tabs[-1].cwd)) + t = self.tabs[-1] + t.windows.append(SpecialWindow(cmd, cwd=t.cwd, override_title=t.next_title)) + t.next_title = None def add_special_window(self, sw): self.tabs[-1].windows.append(sw) @@ -78,6 +84,8 @@ def parse_session(raw, opts): ans.set_enabled_layouts(rest) elif cmd == 'cd': ans.set_cwd(rest) + elif cmd == 'title': + ans.set_next_title(rest) else: raise ValueError('Unknown command in session file: {}'.format(cmd)) for t in ans.tabs: