This commit is contained in:
Kovid Goyal 2021-04-23 16:23:13 +05:30
parent d782654819
commit cbf33fa14b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 22 additions and 5 deletions

View File

@ -29,6 +29,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- GNOME: Fix maximize state not being remembered when focus changes and window
decorations are hidden (:iss:`3507`)
- Fix reading :option:`kitty --session` from ``STDIN`` not working when the
:option:`kitty --detach` option is used (:iss:`3523`)
0.20.1 [2021-04-19]
----------------------

View File

@ -306,6 +306,9 @@ def _main() -> None:
create_opts(cli_opts, debug_config=True)
return
if cli_opts.detach:
if cli_opts.session == '-':
from .session import PreReadSession
cli_opts.session = PreReadSession(sys.stdin.read())
detach()
if cli_opts.replay_commands:
from kitty.client import main as client_main

View File

@ -137,6 +137,14 @@ def parse_session(raw: str, opts: Options, default_title: Optional[str] = None)
yield finalize_session(ans)
class PreReadSession(str):
def __new__(cls, val: str) -> 'PreReadSession':
ans: PreReadSession = str.__new__(cls, val)
ans.pre_read = True # type: ignore
return ans
def create_sessions(
opts: Options,
args: Optional[CLIOptions] = None,
@ -146,12 +154,15 @@ def create_sessions(
default_session: Optional[str] = None
) -> Generator[Session, None, None]:
if args and args.session:
if args.session == '-':
f = sys.stdin
if isinstance(args.session, PreReadSession):
session_data = '' + str(args.session)
else:
f = open(args.session)
with f:
session_data = f.read()
if args.session == '-':
f = sys.stdin
else:
f = open(args.session)
with f:
session_data = f.read()
yield from parse_session(session_data, opts, getattr(args, 'title', None))
return
if default_session and default_session != 'none':