Merge branch 'feat-path-search' of https://github.com/page-down/kitty

This commit is contained in:
Kovid Goyal 2021-12-09 11:41:37 +05:30
commit ecdf901c19
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 8 additions and 17 deletions

View File

@ -294,10 +294,9 @@ def render_as_single_image(
def can_display_images() -> bool: def can_display_images() -> bool:
import shutil
ans: Optional[bool] = getattr(can_display_images, 'ans', None) ans: Optional[bool] = getattr(can_display_images, 'ans', None)
if ans is None: if ans is None:
ans = shutil.which('convert') is not None ans = which('convert') is not None
setattr(can_display_images, 'ans', ans) setattr(can_display_images, 'ans', ans)
return ans return ans

View File

@ -58,9 +58,8 @@ from .typing import PopenType, TypedDict
from .utils import ( from .utils import (
func_name, get_editor, get_new_os_window_size, get_primary_selection, func_name, get_editor, get_new_os_window_size, get_primary_selection,
is_path_in_temp_dir, log_error, open_url, parse_address_spec, is_path_in_temp_dir, log_error, open_url, parse_address_spec,
parse_uri_list, platform_window_id, read_shell_environment, parse_uri_list, platform_window_id, remove_socket_file, safe_print,
remove_socket_file, safe_print, set_primary_selection, single_instance, set_primary_selection, single_instance, startup_notification_handler
startup_notification_handler
) )
from .window import CommandOutput, MatchPatternType, Window from .window import CommandOutput, MatchPatternType, Window
@ -1282,14 +1281,8 @@ class Boss:
cmd = list(map(prepare_arg, get_options().scrollback_pager)) cmd = list(map(prepare_arg, get_options().scrollback_pager))
if not os.path.isabs(cmd[0]): if not os.path.isabs(cmd[0]):
import shutil from .utils import which
exe = shutil.which(cmd[0]) cmd[0] = which(cmd[0]) or 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
if os.path.basename(cmd[0]) == 'less': if os.path.basename(cmd[0]) == 'less':
cmd.append('-+F') # reset --quit-if-one-screen cmd.append('-+F') # reset --quit-if-one-screen

View File

@ -364,8 +364,8 @@ class Tab: # {{{
if check_for_suitability: if check_for_suitability:
old_exe = cmd[0] old_exe = cmd[0]
if not os.path.isabs(old_exe): if not os.path.isabs(old_exe):
import shutil from .utils import which
actual_exe = shutil.which(old_exe) actual_exe = which(old_exe)
old_exe = actual_exe if actual_exe else os.path.abspath(old_exe) old_exe = actual_exe if actual_exe else os.path.abspath(old_exe)
try: try:
is_executable = os.access(old_exe, os.X_OK) is_executable = os.access(old_exe, os.X_OK)

View File

@ -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]: def get_editor_from_env_vars(opts: Optional[Options] = None) -> List[str]:
import shlex import shlex
import shutil
editor = get_editor_from_env(os.environ) editor = get_editor_from_env(os.environ)
if not editor: 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) editor = get_editor_from_env(shell_env)
for ans in (editor, 'vim', 'nvim', 'vi', 'emacs', 'kak', 'micro', 'nano', 'vis'): 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 break
else: else:
ans = 'vim' ans = 'vim'