mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Also use cwd of child when opening programs via the hints kitten
This commit is contained in:
@@ -306,7 +306,11 @@ def handle_result(args, data, target_window_id, boss):
|
|||||||
elif program == '@':
|
elif program == '@':
|
||||||
set_clipboard_string(data['match'])
|
set_clipboard_string(data['match'])
|
||||||
else:
|
else:
|
||||||
boss.open_url(data['match'], None if program == 'default' else program)
|
cwd = None
|
||||||
|
w = boss.window_id_map.get(target_window_id)
|
||||||
|
if w is not None:
|
||||||
|
cwd = w.cwd_of_child
|
||||||
|
boss.open_url(data['match'], None if program == 'default' else program, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -563,11 +563,11 @@ class Boss:
|
|||||||
old_focus.focus_changed(False)
|
old_focus.focus_changed(False)
|
||||||
tab.active_window.focus_changed(True)
|
tab.active_window.focus_changed(True)
|
||||||
|
|
||||||
def open_url(self, url, program=None):
|
def open_url(self, url, program=None, cwd=None):
|
||||||
if url:
|
if url:
|
||||||
if isinstance(program, str):
|
if isinstance(program, str):
|
||||||
program = to_cmdline(program)
|
program = to_cmdline(program)
|
||||||
open_url(url, program or self.opts.open_url_with)
|
open_url(url, program or self.opts.open_url_with, cwd=cwd)
|
||||||
|
|
||||||
def open_url_lines(self, lines, program=None):
|
def open_url_lines(self, lines, program=None):
|
||||||
self.open_url(''.join(lines), program)
|
self.open_url(''.join(lines), program)
|
||||||
|
|||||||
@@ -330,6 +330,14 @@ class Window:
|
|||||||
lines = h + lines
|
lines = h + lines
|
||||||
return ''.join(lines)
|
return ''.join(lines)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cwd_of_child(self):
|
||||||
|
# TODO: Maybe use the cwd of the leader of the foreground process
|
||||||
|
# group?
|
||||||
|
pid = self.child.pid
|
||||||
|
if pid is not None:
|
||||||
|
return cwd_of_process(pid) or None
|
||||||
|
|
||||||
# actions {{{
|
# actions {{{
|
||||||
|
|
||||||
def show_scrollback(self):
|
def show_scrollback(self):
|
||||||
@@ -349,8 +357,7 @@ class Window:
|
|||||||
set_clipboard_string(text)
|
set_clipboard_string(text)
|
||||||
|
|
||||||
def pass_selection_to_program(self, *args):
|
def pass_selection_to_program(self, *args):
|
||||||
pid = self.child.pid
|
cwd = self.cwd_of_child
|
||||||
cwd = cwd_of_process(pid)
|
|
||||||
text = self.text_for_selection()
|
text = self.text_for_selection()
|
||||||
if text:
|
if text:
|
||||||
if args:
|
if args:
|
||||||
|
|||||||
Reference in New Issue
Block a user