mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
When calling pass_selection_to_program use the current directory of the child process as the cwd of the program. Fixes #491
This commit is contained in:
@@ -120,15 +120,15 @@ def command_for_open(program='default'):
|
|||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def open_cmd(cmd, arg=None):
|
def open_cmd(cmd, arg=None, cwd=None):
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
cmd = list(cmd)
|
cmd = list(cmd)
|
||||||
cmd.append(arg)
|
cmd.append(arg)
|
||||||
return subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
return subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=cwd or None)
|
||||||
|
|
||||||
|
|
||||||
def open_url(url, program='default'):
|
def open_url(url, program='default', cwd=None):
|
||||||
return open_cmd(command_for_open(program), url)
|
return open_cmd(command_for_open(program), url, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
def detach(fork=True, setsid=True, redirect=True):
|
def detach(fork=True, setsid=True, redirect=True):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import weakref
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
from .child import cwd_of_process
|
||||||
from .config import build_ansi_color_table, parse_send_text_bytes
|
from .config import build_ansi_color_table, parse_send_text_bytes
|
||||||
from .constants import (
|
from .constants import (
|
||||||
ScreenGeometry, WindowGeometry, appname, get_boss, wakeup
|
ScreenGeometry, WindowGeometry, appname, get_boss, wakeup
|
||||||
@@ -348,12 +349,14 @@ 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 = cwd_of_process(pid)
|
||||||
text = self.text_for_selection()
|
text = self.text_for_selection()
|
||||||
if text:
|
if text:
|
||||||
if args:
|
if args:
|
||||||
open_cmd(args, text)
|
open_cmd(args, text, cwd=cwd)
|
||||||
else:
|
else:
|
||||||
open_url(text)
|
open_url(text, cwd=cwd)
|
||||||
|
|
||||||
def scroll_line_up(self):
|
def scroll_line_up(self):
|
||||||
if self.screen.is_main_linebuf():
|
if self.screen.is_main_linebuf():
|
||||||
|
|||||||
Reference in New Issue
Block a user