Better fix for kitten not being in PATH

Add it to PATH just as we add the kitty dir to PATH. Ensures the correct
kitten is in PATH, corresponding to the correct kitty.
This commit is contained in:
Kovid Goyal 2023-02-01 10:16:50 +05:30
parent 6ea812679f
commit fbbfb25702
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 17 additions and 8 deletions

View File

@ -40,6 +40,9 @@ Detailed list of changes
- Fix :opt:`modify_font` not working for strikethrough position (:iss:`5946`)
- Fix a regression causing the ``edit-in-kitty`` command not working if :file:`kitten` is not added
to PATH (:iss:`5956`)
0.27.0 [2023-01-31]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -23,6 +23,7 @@ from .constants import (
glfw_path,
is_macos,
is_wayland,
kitten_exe,
kitty_exe,
logo_png_file,
running_in_kitty,
@ -382,6 +383,15 @@ def ensure_kitty_in_path() -> None:
os.environ['PATH'] = prepend_if_not_present(rpath, env_path)
def ensure_kitten_in_path() -> None:
correct_kitten = kitten_exe()
existing = shutil.which('kitten')
if existing and safe_samefile(existing, correct_kitten):
return
env_path = os.environ.get('PATH', '')
os.environ['PATH'] = prepend_if_not_present(os.path.dirname(correct_kitten), env_path)
def setup_manpath(env: Dict[str, str]) -> None:
# Ensure kitty manpages are available in frozen builds
if not getattr(sys, 'frozen', False):
@ -407,6 +417,7 @@ def setup_environment(opts: Options, cli_opts: CLIOptions) -> None:
cli_opts.listen_on = expand_listen_on(cli_opts.listen_on, from_config_file)
env = opts.env.copy()
ensure_kitty_in_path()
ensure_kitten_in_path()
kitty_path = shutil.which('kitty')
if kitty_path:
child_path = env.get('PATH')

View File

@ -7,7 +7,7 @@ import subprocess
from contextlib import suppress
from typing import Callable, Dict, List, Optional
from .constants import kitten_exe, shell_integration_dir
from .constants import shell_integration_dir
from .fast_data_types import get_options
from .options.types import Options, defaults
from .utils import log_error, which
@ -221,7 +221,6 @@ def modify_shell_environ(opts: Options, env: Dict[str, str], argv: List[str]) ->
if shell is None or not ksi:
return
env['KITTY_SHELL_INTEGRATION'] = ksi
env['KITTY_KITTEN_EXE'] = kitten_exe()
if not shell_integration_allows_rc_modification(opts):
return
f = ENV_MODIFIERS.get(shell)

View File

@ -209,9 +209,7 @@ _ksi_main() {
_ksi_prompt[ps0]+="\[\e]133;C\a\]"
fi
[[ -z "${KITTY_KITTEN_EXE}" ]] && KITTY_KITTEN_EXE="kitten"
alias edit-in-kitty="${KITTY_KITTEN_EXE} edit-in-kitty"
builtin unset KITTY_KITTEN_EXE
alias edit-in-kitty="kitten edit-in-kitty"
if [[ "${_ksi_prompt[complete]}" == "y" ]]; then
_ksi_completions() {

View File

@ -386,9 +386,7 @@ _ksi_deferred_init() {
fi
builtin unset KITTY_IS_CLONE_LAUNCH KITTY_CLONE_SOURCE_STRATEGIES
[[ -z "${KITTY_KITTEN_EXE}" ]] && KITTY_KITTEN_EXE="kitten"
alias edit-in-kitty="${KITTY_KITTEN_EXE} edit-in-kitty"
builtin unset KITTY_KITTEN_EXE
alias edit-in-kitty="kitten edit-in-kitty"
# Map alt+left/right to move by word if not already mapped. This is expected behavior on macOS and I am tired
# of answering questions about it.