From 47641456dad9fee3e228dfa8361fdc88db317861 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 31 Jan 2023 20:41:39 +0530 Subject: [PATCH] Ensure edit-in-kitty works even if kitten is not in PATH Still needs to be implemented for fish shell --- kitty/shell_integration.py | 3 ++- shell-integration/bash/kitty.bash | 5 ++++- shell-integration/zsh/kitty-integration | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kitty/shell_integration.py b/kitty/shell_integration.py index f1a8dc22a..3f8c9767e 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 shell_integration_dir +from .constants import kitten_exe, shell_integration_dir from .fast_data_types import get_options from .options.types import Options, defaults from .utils import log_error, which @@ -221,6 +221,7 @@ 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 7cc936c3d..694d1fc47 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -209,7 +209,10 @@ _ksi_main() { _ksi_prompt[ps0]+="\[\e]133;C\a\]" fi - alias edit-in-kitty="kitten edit-in-kitty" + [[ -z "${KITTY_KITTEN_EXE}" ]] && KITTY_KITTEN_EXE="kitten" + alias edit-in-kitty="${KITTY_KITTEN_EXE} edit-in-kitty" + builtin unset KITTY_KITTEN_EXE + if [[ "${_ksi_prompt[complete]}" == "y" ]]; then _ksi_completions() { builtin local src diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index bace0e38a..260763319 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -386,7 +386,9 @@ _ksi_deferred_init() { fi builtin unset KITTY_IS_CLONE_LAUNCH KITTY_CLONE_SOURCE_STRATEGIES - alias edit-in-kitty="kitten edit-in-kitty" + [[ -z "${KITTY_KITTEN_EXE}" ]] && KITTY_KITTEN_EXE="kitten" + alias edit-in-kitty="${KITTY_KITTEN_EXE} edit-in-kitty" + builtin unset KITTY_KITTEN_EXE # 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.