Shell integration: preserve TERMINFO when using run0

This commit is contained in:
Arthur Cerqueira 2026-10-18 10:02:34 -03:00 • committed by Kovid Goyal
parent 56deb9e86d
commit ce6ab5124e
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 24 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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