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` tabbed file, see :opt:`tab_bar_style`
- Fix :option:`kitty --title` not overriding the OS Window title when multiple - 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] 0.22.2 [2021-08-02]

View File

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

View File

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