Change the semantics of --title slightly

Now it no longer overrides the titles of windows/tabs created in the
session. This allows windows/tabs to have their own titles while fixing
the OS Window's title.
This commit is contained in:
Kovid Goyal 2021-08-03 09:51:53 +05:30
parent 70b5f5bce3
commit 2d7032973c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 13 deletions

View File

@ -11,7 +11,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
tabbed file, see :opt:`tab_bar_style`
- Fix :option:`kitty --title` not overriding the OS Window title when multiple
tabs are present (:iss:`3893`)
tabs are present. Also this option is no longer used as the default title for
windows, allowing individual tabs/windows to have their own titles, even when
the OS Window has a fixed overall title (:iss:`3893`)
0.22.2 [2021-08-02]

View File

@ -596,10 +596,8 @@ def options_spec() -> str:
--title -T
Set the OS window title. This will override any title set by the program running inside kitty. So
only use this if you are running a program that does not set titles. If combined
with :option:`{appname} --session` the title will be used for all windows created by the
session, that do not set their own titles.
Set the OS window title. This will override any title set by the program running inside kitty, permanently
fixing the OS Window's title. So only use this if you are running a program that does not set titles.
--config -c

View File

@ -90,16 +90,16 @@ def set_cwd(self, val: str) -> None:
self.tabs[-1].cwd = val
def parse_session(raw: str, opts: Options, default_title: Optional[str] = None) -> Generator[Session, None, None]:
def parse_session(raw: str, opts: Options) -> Generator[Session, None, None]:
def finalize_session(ans: Session) -> Session:
from .tabs import SpecialWindow
for t in ans.tabs:
if not t.windows:
t.windows.append(SpecialWindow(cmd=resolved_shell(opts), override_title=default_title))
t.windows.append(SpecialWindow(cmd=resolved_shell(opts)))
return ans
ans = Session(default_title)
ans = Session()
ans.add_tab(opts)
for line in raw.splitlines():
line = line.strip()
@ -114,7 +114,7 @@ def finalize_session(ans: Session) -> Session:
ans.add_tab(opts, rest)
elif cmd == 'new_os_window':
yield finalize_session(ans)
ans = Session(default_title)
ans = Session()
ans.add_tab(opts, rest)
elif cmd == 'layout':
ans.set_layout(rest)
@ -164,7 +164,7 @@ def create_sessions(
f = open(args.session)
with f:
session_data = f.read()
yield from parse_session(session_data, opts, getattr(args, 'title', None))
yield from parse_session(session_data, opts)
return
if default_session and default_session != 'none':
try:
@ -173,7 +173,7 @@ def create_sessions(
except OSError:
log_error('Failed to read from session file, ignoring: {}'.format(default_session))
else:
yield from parse_session(session_data, opts, getattr(args, 'title', None))
yield from parse_session(session_data, opts)
return
default_watchers = args.watcher if args else ()
ans = Session(default_watchers=default_watchers)
@ -186,7 +186,6 @@ def create_sessions(
cmd = [kitty_exe(), '+hold'] + cmd
from kitty.tabs import SpecialWindow
cwd: Optional[str] = args.directory if respect_cwd and args else None
title = getattr(args, 'title', None)
special_window = SpecialWindow(cmd, override_title=title, cwd_from=cwd_from, cwd=cwd)
special_window = SpecialWindow(cmd, cwd_from=cwd_from, cwd=cwd)
ans.add_special_window(special_window)
yield ans