Add an option to kitty.conf to specify a default startup session
Fixes #641
This commit is contained in:
parent
26f50a451e
commit
12cbcf1c17
3 changed files with 17 additions and 2 deletions
|
|
@ -96,7 +96,7 @@ def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigge
|
|||
)
|
||||
set_boss(self)
|
||||
self.opts, self.args = opts, args
|
||||
startup_session = create_session(opts, args)
|
||||
startup_session = create_session(opts, args, default_session=opts.startup_session)
|
||||
self.keymap = self.opts.keymap.copy()
|
||||
if new_os_window_trigger is not None:
|
||||
self.keymap.pop(new_os_window_trigger, None)
|
||||
|
|
|
|||
|
|
@ -616,6 +616,12 @@ def tab_fade(x):
|
|||
Note that this even works over ssh connections.
|
||||
'''))
|
||||
|
||||
o('startup_session', 'none', option_type=lambda x: (None if x.lower() == 'none' else x), long_text=_('''
|
||||
Path to a session file to use for all kitty instances. Can be overridden
|
||||
by using the :option:`--startup-session` command line option for individual
|
||||
instances. See :ref:`sessions` in the kitty documentation for details.
|
||||
'''))
|
||||
|
||||
o('clipboard_control', 'write-clipboard write-primary', option_type=lambda x: frozenset(x.lower().split()), long_text=_('''
|
||||
Allow programs running in kitty to read and write from the clipboard. You can
|
||||
control exactly which actions are allowed. The set of possible actions is:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
from .config_data import to_layout_names
|
||||
from .constants import shell_path
|
||||
from .layout import all_layouts
|
||||
from .utils import log_error
|
||||
|
||||
|
||||
class Tab:
|
||||
|
|
@ -105,10 +106,18 @@ def parse_session(raw, opts):
|
|||
return ans
|
||||
|
||||
|
||||
def create_session(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False):
|
||||
def create_session(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False, default_session=None):
|
||||
if args and args.session:
|
||||
with open(args.session) as f:
|
||||
return parse_session(f.read(), opts)
|
||||
if default_session and default_session != 'none':
|
||||
try:
|
||||
with open(default_session) as f:
|
||||
session_data = f.read()
|
||||
except EnvironmentError:
|
||||
log_error('Failed to read from session file, ignoring: {}'.format(default_session))
|
||||
else:
|
||||
return parse_session(session_data, opts)
|
||||
ans = Session()
|
||||
current_layout = opts.enabled_layouts[0] if opts.enabled_layouts else 'tall'
|
||||
ans.add_tab(opts)
|
||||
|
|
|
|||
Loading…
Reference in a new issue