mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
Only alias sudo if no systemwide terminfo db for xterm-kitty is found
This commit is contained in:
parent
a54586dfa9
commit
2aa37de6ff
@ -16,7 +16,7 @@ if [[ -n "$KITTY_BASH_INJECT" ]]; then
|
||||
[[ -f "$1" && -r "$1" ]] && builtin return 0; builtin return 1;
|
||||
}
|
||||
|
||||
if [[ -n "$ksi_val" && "$ksi_val" != *no-sudo* ]]; then
|
||||
if [[ -n "$ksi_val" && "$ksi_val" != *no-sudo* && -n "$TERMINFO" && ! ( -r "/usr/share/terminfo/x/xterm-kitty" || -r "/usr/share/terminfo/78/xterm-kitty" ) ]]; then
|
||||
# this must be done before sourcing user bashrc otherwise aliasing of sudo does not work
|
||||
sudo() {
|
||||
# Ensure terminfo is available in sudo
|
||||
@ -28,7 +28,7 @@ if [[ -n "$KITTY_BASH_INJECT" ]]; then
|
||||
fi
|
||||
[[ "$arg" != -* && "$arg" != *=* ]] && builtin break # command found
|
||||
done
|
||||
if [[ -z "$TERMINFO" || "$is_sudoedit" == "y" ]]; then
|
||||
if [[ "$is_sudoedit" == "y" ]]; then
|
||||
builtin command sudo "$@";
|
||||
else
|
||||
builtin command sudo TERMINFO="$TERMINFO" "$@";
|
||||
|
@ -112,6 +112,7 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after
|
||||
# for sudo it will be clobbered by us, so only install this if sudo is not already function
|
||||
if not contains "no-sudo" $_ksi
|
||||
and test -n "$TERMINFO" -a "file" = (type -t sudo)
|
||||
and not test -r "/usr/share/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/78/xterm-kitty"
|
||||
# Ensure terminfo is available in sudo
|
||||
function sudo
|
||||
set --local is_sudoedit "n"
|
||||
|
@ -388,23 +388,25 @@ _ksi_deferred_init() {
|
||||
|
||||
builtin alias edit-in-kitty="kitten edit-in-kitty"
|
||||
|
||||
if (( ! opt[(Ie)no-sudo] )); then
|
||||
sudo() {
|
||||
# Ensure terminfo is available in sudo
|
||||
builtin local is_sudoedit="n"
|
||||
for arg; do
|
||||
if [[ "$arg" == "-e" || $arg == "--edit" ]]; then
|
||||
is_sudoedit="y"
|
||||
builtin break;
|
||||
if (( ! opt[(Ie)no-sudo] )) ; then
|
||||
if [[ -n "$TERMINFO" && ! ( -r "/usr/share/terminfo/x/xterm-kitty" || -r "/usr/share/terminfo/78/xterm-kitty" ) ]]; then
|
||||
sudo() {
|
||||
# Ensure terminfo is available in sudo
|
||||
builtin local is_sudoedit="n"
|
||||
for arg; do
|
||||
if [[ "$arg" == "-e" || $arg == "--edit" ]]; then
|
||||
is_sudoedit="y"
|
||||
builtin break;
|
||||
fi
|
||||
[[ "$arg" != -* && "$arg" != *=* ]] && builtin break # command found
|
||||
done
|
||||
if [[ "$is_sudoedit" == "y" ]]; then
|
||||
builtin command sudo "$@";
|
||||
else
|
||||
builtin command sudo TERMINFO="$TERMINFO" "$@";
|
||||
fi
|
||||
[[ "$arg" != -* && "$arg" != *=* ]] && builtin break # command found
|
||||
done
|
||||
if [[ -z "$TERMINFO" || "$is_sudoedit" == "y" ]]; then
|
||||
builtin command sudo "$@";
|
||||
else
|
||||
builtin command sudo TERMINFO="$TERMINFO" "$@";
|
||||
fi
|
||||
}
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Map alt+left/right to move by word if not already mapped. This is expected behavior on macOS and I am tired
|
||||
|
Loading…
Reference in New Issue
Block a user