Merge branch 'feat-path-search' of https://github.com/page-down/kitty
This commit is contained in:
commit
ecdf901c19
@ -294,10 +294,9 @@ def render_as_single_image(
|
||||
|
||||
|
||||
def can_display_images() -> bool:
|
||||
import shutil
|
||||
ans: Optional[bool] = getattr(can_display_images, 'ans', None)
|
||||
if ans is None:
|
||||
ans = shutil.which('convert') is not None
|
||||
ans = which('convert') is not None
|
||||
setattr(can_display_images, 'ans', ans)
|
||||
return ans
|
||||
|
||||
|
||||
@ -58,9 +58,8 @@ from .typing import PopenType, TypedDict
|
||||
from .utils import (
|
||||
func_name, get_editor, get_new_os_window_size, get_primary_selection,
|
||||
is_path_in_temp_dir, log_error, open_url, parse_address_spec,
|
||||
parse_uri_list, platform_window_id, read_shell_environment,
|
||||
remove_socket_file, safe_print, set_primary_selection, single_instance,
|
||||
startup_notification_handler
|
||||
parse_uri_list, platform_window_id, remove_socket_file, safe_print,
|
||||
set_primary_selection, single_instance, startup_notification_handler
|
||||
)
|
||||
from .window import CommandOutput, MatchPatternType, Window
|
||||
|
||||
@ -1282,14 +1281,8 @@ class Boss:
|
||||
|
||||
cmd = list(map(prepare_arg, get_options().scrollback_pager))
|
||||
if not os.path.isabs(cmd[0]):
|
||||
import shutil
|
||||
exe = shutil.which(cmd[0])
|
||||
if not exe:
|
||||
env = read_shell_environment(get_options())
|
||||
if env and 'PATH' in env:
|
||||
exe = shutil.which(cmd[0], path=env['PATH'])
|
||||
if exe:
|
||||
cmd[0] = exe
|
||||
from .utils import which
|
||||
cmd[0] = which(cmd[0]) or cmd[0]
|
||||
|
||||
if os.path.basename(cmd[0]) == 'less':
|
||||
cmd.append('-+F') # reset --quit-if-one-screen
|
||||
|
||||
@ -364,8 +364,8 @@ class Tab: # {{{
|
||||
if check_for_suitability:
|
||||
old_exe = cmd[0]
|
||||
if not os.path.isabs(old_exe):
|
||||
import shutil
|
||||
actual_exe = shutil.which(old_exe)
|
||||
from .utils import which
|
||||
actual_exe = which(old_exe)
|
||||
old_exe = actual_exe if actual_exe else os.path.abspath(old_exe)
|
||||
try:
|
||||
is_executable = os.access(old_exe, os.X_OK)
|
||||
|
||||
@ -535,7 +535,6 @@ def get_editor_from_env(env: Mapping[str, str]) -> Optional[str]:
|
||||
|
||||
def get_editor_from_env_vars(opts: Optional[Options] = None) -> List[str]:
|
||||
import shlex
|
||||
import shutil
|
||||
|
||||
editor = get_editor_from_env(os.environ)
|
||||
if not editor:
|
||||
@ -543,7 +542,7 @@ def get_editor_from_env_vars(opts: Optional[Options] = None) -> List[str]:
|
||||
editor = get_editor_from_env(shell_env)
|
||||
|
||||
for ans in (editor, 'vim', 'nvim', 'vi', 'emacs', 'kak', 'micro', 'nano', 'vis'):
|
||||
if ans and shutil.which(shlex.split(ans)[0]):
|
||||
if ans and which(shlex.split(ans)[0], only_system=True):
|
||||
break
|
||||
else:
|
||||
ans = 'vim'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user