Allow reading session file from STDIN
This commit is contained in:
parent
3618f4d642
commit
70c2765a6e
@ -514,7 +514,7 @@ Detach from the controlling terminal, if any
|
|||||||
|
|
||||||
--session
|
--session
|
||||||
Path to a file containing the startup :italic:`session` (tabs, windows, layout, programs).
|
Path to a file containing the startup :italic:`session` (tabs, windows, layout, programs).
|
||||||
See the README file for details and an example.
|
Use - to read from STDIN. See the README file for details and an example.
|
||||||
|
|
||||||
|
|
||||||
--hold
|
--hold
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import shlex
|
import shlex
|
||||||
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from .config_data import to_layout_names
|
from .config_data import to_layout_names
|
||||||
from .constants import shell_path, kitty_exe
|
from .constants import kitty_exe, shell_path
|
||||||
from .layout import all_layouts
|
from .layout import all_layouts
|
||||||
from .utils import log_error
|
from .utils import log_error
|
||||||
|
|
||||||
|
|
||||||
WindowSizeOpts = namedtuple(
|
WindowSizeOpts = namedtuple(
|
||||||
'WindowSizeOpts', 'initial_window_width initial_window_height window_margin_width window_padding_width remember_window_size')
|
'WindowSizeOpts', 'initial_window_width initial_window_height window_margin_width window_padding_width remember_window_size')
|
||||||
|
|
||||||
@ -131,9 +131,14 @@ def parse_session(raw, opts, default_title=None):
|
|||||||
|
|
||||||
def create_sessions(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False, default_session=None):
|
def create_sessions(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False, default_session=None):
|
||||||
if args and args.session:
|
if args and args.session:
|
||||||
with open(args.session) as f:
|
if args.session == '-':
|
||||||
yield from parse_session(f.read(), opts, getattr(args, 'title', None))
|
f = sys.stdin
|
||||||
return
|
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':
|
if default_session and default_session != 'none':
|
||||||
try:
|
try:
|
||||||
with open(default_session) as f:
|
with open(default_session) as f:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user