Use find_exe() for resolving editor as well

Avoids having to exec the shell in most cases
This commit is contained in:
Kovid Goyal
2020-12-29 11:33:42 +05:30
parent 08fae7a0ac
commit 65361d56c4
3 changed files with 43 additions and 29 deletions

View File

@@ -14,11 +14,10 @@ from typing import (
Union
)
from kitty.constants import is_macos
from kitty.typing import (
CompletedProcess, GRT_a, GRT_d, GRT_f, GRT_m, GRT_o, GRT_t, HandlerType
)
from kitty.utils import ScreenSize, fit_image
from kitty.utils import ScreenSize, find_exe, fit_image
from .operations import cursor
@@ -76,21 +75,6 @@ def identify(path: str) -> ImageData:
return ImageData(parts[0].lower(), int(parts[1]), int(parts[2]), mode)
def find_exe(name: str) -> Optional[str]:
import shutil
ans = shutil.which(name)
if ans is None:
# In case PATH is messed up
if is_macos:
from kitty.utils import system_paths_on_macos
paths = system_paths_on_macos()
else:
paths = ['/usr/local/bin', '/opt/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']
path = os.pathsep.join(paths) + os.pathsep + os.defpath
ans = shutil.which(name, path=path)
return ans
def convert(
path: str, m: ImageData,
available_width: int, available_height: int,