mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-09 13:45:26 +02:00
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:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@@ -221,7 +222,9 @@ class Boss:
|
|||||||
args, rest = parse_args(msg['args'][1:])
|
args, rest = parse_args(msg['args'][1:])
|
||||||
args.args = rest
|
args.args = rest
|
||||||
opts = create_opts(args)
|
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)
|
self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts, self.cached_values), startup_id=startup_id)
|
||||||
else:
|
else:
|
||||||
log_error('Unknown message received from peer, ignoring')
|
log_error('Unknown message received from peer, ignoring')
|
||||||
|
|||||||
@@ -165,7 +165,9 @@ def _main():
|
|||||||
is_first = single_instance(args.instance_group)
|
is_first = single_instance(args.instance_group)
|
||||||
if not is_first:
|
if not is_first:
|
||||||
import json
|
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')
|
data = json.dumps(data, ensure_ascii=False).encode('utf-8')
|
||||||
single_instance.socket.sendall(data)
|
single_instance.socket.sendall(data)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ def parse_session(raw, opts):
|
|||||||
return ans
|
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:
|
if args and args.session:
|
||||||
with open(args.session) as f:
|
with open(args.session) as f:
|
||||||
return parse_session(f.read(), opts)
|
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)
|
cmd = args.args if args and args.args else resolved_shell(opts)
|
||||||
from kitty.tabs import SpecialWindow
|
from kitty.tabs import SpecialWindow
|
||||||
k = {'cwd_from': cwd_from}
|
k = {'cwd_from': cwd_from}
|
||||||
|
if respect_cwd:
|
||||||
|
k['cwd'] = args.directory
|
||||||
if getattr(args, 'title', None):
|
if getattr(args, 'title', None):
|
||||||
k['override_title'] = args.title
|
k['override_title'] = args.title
|
||||||
special_window = SpecialWindow(cmd, **k)
|
special_window = SpecialWindow(cmd, **k)
|
||||||
|
|||||||
Reference in New Issue
Block a user