diff --git a/kitty/launch.py b/kitty/launch.py index bee67c0ff..b08b7d5fd 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -574,7 +574,10 @@ class CloneCmd: 'CONDA_SHLVL', 'CONDA_PREFIX', 'CONDA_PROMPT_MODIFIER', 'CONDA_EXE', 'CONDA_PYTHON_EXE', '_CE_CONDA', '_CE_M', # skip SSH environment variables 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_ORIGINAL_COMMAND', 'SSH_TTY', 'SSH2_TTY', - }} + } and not k.startswith(( + # conda state env vars for multi-level virtual environments + 'CONDA_PREFIX_', + ))} elif k == 'cwd': self.cwd = v diff --git a/kitty/options/definition.py b/kitty/options/definition.py index bd5247ec9..e2d5c2e6e 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -3768,18 +3768,21 @@ This will send "Special text" when you press the :kbd:`ctrl+alt+a` key combination. The text to be sent is a python string literal so you can use escapes like :code:`\\x1b` to send control codes or :code:`\\u21fb` to send unicode characters (or you can just input the unicode characters directly as -UTF-8 text). The first argument to :code:`send_text` is the keyboard modes in which to -activate the shortcut. The possible values are :code:`normal` or :code:`application` or :code:`kitty` -or a comma separated combination of them. The special keyword :code:`all` means all -modes. The modes :code:`normal` and :code:`application` refer to the DECCKM cursor key mode for -terminals, and :code:`kitty` refers to the special kitty extended keyboard protocol. +UTF-8 text). You can use the show_key kitten :code:`kitty +kitten show_key` to +get the key escape codes you want to emulate. The first argument to +:code:`send_text` is the keyboard modes in which to activate the shortcut. The +possible values are :code:`normal` or :code:`application` or :code:`kitty` or a +comma separated combination of them. The special keyword :code:`all` means all +modes. The modes :code:`normal` and :code:`application` refer to the DECCKM +cursor key mode forterminals, and :code:`kitty` refers to the special kitty +extended keyboard protocol. Some more examples:: - # Output a word and move the cursor ro the start of the line (like typing and pressing Home) + # Output a word and move the cursor to the start of the line (like typing and pressing Home) map ctrl+alt+a send_text normal Word\\x1b[H map ctrl+alt+a send_text application Word\\x1bOH - # Run a command at a shell prompt (like typing the command and pressing enter) + # Run a command at a shell prompt (like typing the command and pressing Enter) map ctrl+alt+a send_text normal,application some command with arguments\r ''' ) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 886d95622..cf0b4186f 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -215,7 +215,7 @@ _ksi_main() { builtin let limit=1+$COMP_CWORD src=$(builtin printf "%s\n" "${COMP_WORDS[@]:0:$limit}" | builtin command kitty +complete bash) if [[ $? == 0 ]]; then - builtin eval ${src} + builtin eval "${src}" fi } builtin complete -o nospace -F _ksi_completions kitty @@ -273,13 +273,13 @@ _ksi_main() { if _ksi_s_is_ok "venv" && [ -n "${VIRTUAL_ENV}" -a -r "$venv" ]; then sourced="y" builtin unset VIRTUAL_ENV - . "$venv" + builtin source "$venv" fi; if _ksi_s_is_ok "conda" && [ -n "${CONDA_DEFAULT_ENV}" ] && builtin command -v conda >/dev/null 2>/dev/null && [ "${CONDA_DEFAULT_ENV}" != "$orig_conda_env" ]; then sourced="y" conda activate "${CONDA_DEFAULT_ENV}" fi; if _ksi_s_is_ok "env_var" && [[ -n "${KITTY_CLONE_SOURCE_CODE}" ]]; then sourced="y" - eval "${KITTY_CLONE_SOURCE_CODE}" + builtin eval "${KITTY_CLONE_SOURCE_CODE}" fi; if _ksi_s_is_ok "path" && [[ -r "${KITTY_CLONE_SOURCE_PATH}" ]]; then sourced="y" builtin source "${KITTY_CLONE_SOURCE_PATH}" diff --git a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish index e32d3fe5b..7ae7ec0dc 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -24,7 +24,6 @@ not functions -q __ksi_schedule || exit 0 set -q fish_killring || set -q status_generation || string match -qnv "3.1.*" "$version" or echo -en \eP@kitty-print\|V2FybmluZzogVXBkYXRlIGZpc2ggdG8gdmVyc2lvbiAzLjMuMCsgdG8gZW5hYmxlIGtpdHR5IHNoZWxsIGludGVncmF0aW9uLgo=\e\\ && exit 0 || exit 0 - function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after other scripts have run, we hope" functions --erase __ksi_schedule test -n "$KITTY_SHELL_INTEGRATION" || return 0 @@ -110,15 +109,14 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after # Handle clone launches if test -n "$KITTY_IS_CLONE_LAUNCH" - set -l orig_conda_env "$CONDA_DEFAULT_ENV" + set --local orig_conda_env "$CONDA_DEFAULT_ENV" eval "$KITTY_IS_CLONE_LAUNCH" - set -l venv "$VIRTUAL_ENV/bin/activate.fish" - set -g _ksi_sourced 'n' + set --local venv "$VIRTUAL_ENV/bin/activate.fish" + set --global _ksi_sourced function _ksi_s_is_ok - if test "$_ksi_sourced" = 'n' - and string match -q -- "*,$argv[1],*" "$KITTY_CLONE_SOURCE_STRATEGIES" - return 0 - end + test -z "$_ksi_sourced" + and string match -q -- "*,$argv[1],*" "$KITTY_CLONE_SOURCE_STRATEGIES" + and return 0 return 1 end if _ksi_s_is_ok "venv" @@ -128,9 +126,8 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after source "$venv" end if _ksi_s_is_ok "conda" - and test -n "$CONDA_DEFAULT_ENV" - and type -q conda - and test "$CONDA_DEFAULT_ENV" != "$orig_conda_env" + and test -n "$CONDA_DEFAULT_ENV" -a "$CONDA_DEFAULT_ENV" != "$orig_conda_env" + and functions -q conda set _ksi_sourced "y" conda activate "$CONDA_DEFAULT_ENV" end @@ -146,6 +143,15 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after end set --erase KITTY_IS_CLONE_LAUNCH KITTY_CLONE_SOURCE_STRATEGIES _ksi_sourced functions --erase _ksi_s_is_ok + + # Ensure PATH has no duplicate entries + set --local --path new_path + for p in $PATH + contains -- "$p" $new_path + or set --append new_path "$p" + end + test (count $new_path) -eq (count $PATH) + or set --global --export --path PATH $new_path end end @@ -165,9 +171,9 @@ function clone-in-kitty -d "Clone the current fish session into a new kitty wind for e in (set --export --names) set --append envs "$e=$$e" end - set --local b64_envs (string join0 $envs | base64) + set --local b64_envs (string join0 -- $envs | base64) set --local b64_cwd (printf "%s" "$PWD" | base64) - set --prepend data "shell=fish,pid=$fish_pid" "cwd=$b64_cwd" "env=$b64_envs" + set --prepend data "shell=fish" "pid=$fish_pid" "cwd=$b64_cwd" "env=$b64_envs" set data (string join "," -- $data | tr -d "\t\n\r ") set --local data_len (string length -- "$data") set --local pos 1 diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index 2433b8ea3..7efe5bc1e 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -369,7 +369,7 @@ _ksi_deferred_init() { conda activate "${CONDA_DEFAULT_ENV}" fi; if _ksi_s_is_ok "env_var" && [[ -n "${KITTY_CLONE_SOURCE_CODE}" ]]; then sourced="y" - eval "${KITTY_CLONE_SOURCE_CODE}" + builtin eval "${KITTY_CLONE_SOURCE_CODE}" fi; if _ksi_s_is_ok "path" && [[ -r "${KITTY_CLONE_SOURCE_PATH}" ]]; then sourced="y" builtin source "${KITTY_CLONE_SOURCE_PATH}"