Use the launch time argv for cmdline on macOS
This commit is contained in:
parent
464c7a80e2
commit
c6d10c6a23
@ -78,3 +78,17 @@ class Child:
|
|||||||
os.close(stdin_read_fd)
|
os.close(stdin_read_fd)
|
||||||
fast_data_types.thread_write(stdin_write_fd, stdin)
|
fast_data_types.thread_write(stdin_write_fd, stdin)
|
||||||
return pid
|
return pid
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cmdline(self):
|
||||||
|
try:
|
||||||
|
return cmdline_of_process(self.pid)
|
||||||
|
except Exception:
|
||||||
|
return list(self.argv)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_cwd(self):
|
||||||
|
try:
|
||||||
|
return cwd_of_process(self.pid)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import weakref
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from .child import cmdline_of_process, 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
|
||||||
@ -109,19 +108,11 @@ class Window:
|
|||||||
return 'Window(title={}, id={})'.format(self.title, self.id)
|
return 'Window(title={}, id={})'.format(self.title, self.id)
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
try:
|
|
||||||
cwd = cwd_of_process(self.child.pid)
|
|
||||||
except Exception:
|
|
||||||
cwd = None
|
|
||||||
try:
|
|
||||||
cmdline = cmdline_of_process(self.child.pid)
|
|
||||||
except Exception:
|
|
||||||
cmdline = None
|
|
||||||
return dict(
|
return dict(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
title=self.override_title or self.title,
|
title=self.override_title or self.title,
|
||||||
pid=self.child.pid,
|
pid=self.child.pid,
|
||||||
cwd=cwd, cmdline=cmdline
|
cwd=self.child.current_cwd or self.child.cwd, cmdline=self.child.cmdline
|
||||||
)
|
)
|
||||||
|
|
||||||
def matches(self, field, pat):
|
def matches(self, field, pat):
|
||||||
@ -132,17 +123,9 @@ class Window:
|
|||||||
if field == 'title':
|
if field == 'title':
|
||||||
return pat.search(self.override_title or self.title) is not None
|
return pat.search(self.override_title or self.title) is not None
|
||||||
if field in 'cwd':
|
if field in 'cwd':
|
||||||
try:
|
return pat.search(self.child.current_cwd or self.child.cwd) is not None
|
||||||
cwd = cwd_of_process(self.child.pid)
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
return pat.search(cwd) is not None
|
|
||||||
if field == 'cmdline':
|
if field == 'cmdline':
|
||||||
try:
|
for x in self.child.cmdline:
|
||||||
cmdline = cmdline_of_process(self.child.pid)
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
for x in cmdline:
|
|
||||||
if pat.search(x) is not None:
|
if pat.search(x) is not None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user