diff --git a/docs/changelog.rst b/docs/changelog.rst index 7651c106b..218ad44cb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/main.py b/kitty/main.py index 4e29a1760..4f20f6c95 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -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') diff --git a/kitty/shell_integration.py b/kitty/shell_integration.py index 3f8c9767e..f1a8dc22a 100644 --- a/kitty/shell_integration.py +++ b/kitty/shell_integration.py @@ -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) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 694d1fc47..9d8ef23b2 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -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() { diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index 260763319..bace0e38a 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -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.