From 5b28aed0b116621c7dad5e0b3fe60ef13399fb4c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Aug 2022 20:11:18 +0530 Subject: [PATCH] Allow the set_tab_title action to take an argument --- kitty/boss.py | 11 +++++++++-- kitty/options/utils.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index 6fc045621..76d0f6e40 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1579,10 +1579,17 @@ class Boss: def input_unicode_character(self) -> None: self.run_kitten_with_metadata('unicode_input') - @ac('tab', 'Change the title of the active tab') - def set_tab_title(self) -> None: + @ac( + 'tab', + 'Change the title of the active tab interactively, by typing in the new title. If you specify an argument' + ' to this action then that is used as the title instead of asking for it.' + ) + def set_tab_title(self, title: str = '') -> None: tab = self.active_tab if tab: + if title: + tab.set_title(title) + return args = [ '--name=tab-title', '--message', _('Enter the new title for this tab below.'), '--default', tab.name or tab.title, 'do_set_tab_title', str(tab.id)] diff --git a/kitty/options/utils.py b/kitty/options/utils.py index 749018559..64d2400f2 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -136,7 +136,7 @@ def detach_tab_parse(func: str, rest: str) -> FuncArgsType: return func, (rest,) -@func_with_args('set_background_opacity', 'goto_layout', 'toggle_layout', 'kitty_shell', 'show_kitty_doc') +@func_with_args('set_background_opacity', 'goto_layout', 'toggle_layout', 'kitty_shell', 'show_kitty_doc', 'set_tab_title') def simple_parse(func: str, rest: str) -> FuncArgsType: return func, [rest]