Also use cwd of child when opening programs via the hints kitten
This commit is contained in:
parent
23851e31bf
commit
316e7cb9f5
@ -306,7 +306,11 @@ def handle_result(args, data, target_window_id, boss):
|
||||
elif program == '@':
|
||||
set_clipboard_string(data['match'])
|
||||
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__':
|
||||
|
||||
@ -563,11 +563,11 @@ class Boss:
|
||||
old_focus.focus_changed(False)
|
||||
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 isinstance(program, str):
|
||||
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):
|
||||
self.open_url(''.join(lines), program)
|
||||
|
||||
@ -330,6 +330,14 @@ class Window:
|
||||
lines = h + 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 {{{
|
||||
|
||||
def show_scrollback(self):
|
||||
@ -349,8 +357,7 @@ class Window:
|
||||
set_clipboard_string(text)
|
||||
|
||||
def pass_selection_to_program(self, *args):
|
||||
pid = self.child.pid
|
||||
cwd = cwd_of_process(pid)
|
||||
cwd = self.cwd_of_child
|
||||
text = self.text_for_selection()
|
||||
if text:
|
||||
if args:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user