Fix using kitty --single-instance to open a new window in a running kitty instance, not respecting the --directory flag. Fixes #429
This commit is contained in:
parent
43ce3ce4b0
commit
ce0db16479
@ -4,6 +4,7 @@
|
||||
|
||||
import atexit
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
from functools import partial
|
||||
@ -221,7 +222,9 @@ class Boss:
|
||||
args, rest = parse_args(msg['args'][1:])
|
||||
args.args = rest
|
||||
opts = create_opts(args)
|
||||
session = create_session(opts, args)
|
||||
if not os.path.isabs(args.directory):
|
||||
args.directory = os.path.join(msg['cwd'], args.directory)
|
||||
session = create_session(opts, args, respect_cwd=True)
|
||||
self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts, self.cached_values), startup_id=startup_id)
|
||||
else:
|
||||
log_error('Unknown message received from peer, ignoring')
|
||||
|
||||
@ -165,7 +165,9 @@ def _main():
|
||||
is_first = single_instance(args.instance_group)
|
||||
if not is_first:
|
||||
import json
|
||||
data = {'cmd': 'new_instance', 'args': tuple(sys.argv), 'startup_id': os.environ.get('DESKTOP_STARTUP_ID')}
|
||||
data = {'cmd': 'new_instance', 'args': tuple(sys.argv),
|
||||
'startup_id': os.environ.get('DESKTOP_STARTUP_ID'),
|
||||
'cwd': os.getcwd()}
|
||||
data = json.dumps(data, ensure_ascii=False).encode('utf-8')
|
||||
single_instance.socket.sendall(data)
|
||||
return
|
||||
|
||||
@ -105,7 +105,7 @@ def parse_session(raw, opts):
|
||||
return ans
|
||||
|
||||
|
||||
def create_session(opts, args=None, special_window=None, cwd_from=None):
|
||||
def create_session(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False):
|
||||
if args and args.session:
|
||||
with open(args.session) as f:
|
||||
return parse_session(f.read(), opts)
|
||||
@ -122,6 +122,8 @@ def create_session(opts, args=None, special_window=None, cwd_from=None):
|
||||
cmd = args.args if args and args.args else resolved_shell(opts)
|
||||
from kitty.tabs import SpecialWindow
|
||||
k = {'cwd_from': cwd_from}
|
||||
if respect_cwd:
|
||||
k['cwd'] = args.directory
|
||||
if getattr(args, 'title', None):
|
||||
k['override_title'] = args.title
|
||||
special_window = SpecialWindow(cmd, **k)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user