From ce6ab5124ea7d8635b73dc0a72f0490fa15bb431 Mon Sep 17 00:00:00 2001 From: Arthur Cerqueira Date: Sun, 18 Oct 2026 10:02:34 -0300 Subject: [PATCH] Shell integration: preserve TERMINFO when using run0 --- docs/shell-integration.rst | 12 ++++++------ shell-integration/bash/kitty.bash | 4 ++++ .../fish/vendor_conf.d/kitty-shell-integration.fish | 10 ++++++++++ shell-integration/zsh/kitty-integration | 4 ++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/shell-integration.rst b/docs/shell-integration.rst index ce05d6c93..6fc19ca30 100644 --- a/docs/shell-integration.rst +++ b/docs/shell-integration.rst @@ -94,12 +94,12 @@ no-complete comes with a kitty completion script. no-sudo - Do not alias :program:`sudo` to ensure the kitty terminfo files are - available in the sudo environment. This is needed if you have sudo - configured to disable setting of environment variables on the command line. - By default, if sudo is configured to allow all commands for the current - user, setting of environment variables at the command line is also allowed. - Only if commands are restricted is this needed. + Do not alias :program:`sudo` and :program:`run0` to ensure the kitty + terminfo files are available in the sudo/run0 environment. This is needed + if you have sudo configured to disable setting of environment variables on + the command line. By default, if sudo is configured to allow all commands + for the current user, setting of environment variables at the command line + is also allowed. Only if commands are restricted is this needed. More ways to browse command output diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 67acd91e6..cfdc61548 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -45,6 +45,10 @@ if [[ -n "$KITTY_BASH_INJECT" ]]; then builtin command sudo TERMINFO="$TERMINFO" "$@"; fi } + run0() { + # Ensure terminfo is available in run0, --setenv=NAME copies NAME from the current env + builtin command run0 --setenv=TERMINFO "$@"; + } fi if [[ "$kitty_bash_inject" == *"posix"* ]]; then 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 e2637d5fa..795c5ab2a 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -186,6 +186,16 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after end end + # Same as above for run0 + if not contains "no-sudo" $_ksi + and test -n "$TERMINFO" -a "file" = (type -t run0 2> /dev/null || echo "x") + and not test -r "/usr/share/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/78/xterm-kitty" + # Ensure terminfo is available in run0, --setenv=NAME copies NAME from the current env + function run0 + command run0 --setenv=TERMINFO $argv + end + end + # Handle clone launches if test -n "$KITTY_IS_CLONE_LAUNCH" set --local orig_conda_env "$CONDA_DEFAULT_ENV" diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index f4eab14cc..1d2858478 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -431,6 +431,10 @@ _ksi_deferred_init() { builtin command sudo TERMINFO="$TERMINFO" "$@"; fi } + run0() { + # Ensure terminfo is available in run0, --setenv=NAME copies NAME from the current env + builtin command run0 --setenv=TERMINFO "$@"; + } fi fi