mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
zsh integration: Use a function for sudo
This fixes sudo --edit and works around the zsh sudo completions bug: https://www.zsh.org/mla/workers/2023/msg00983.html
This commit is contained in:
@@ -389,8 +389,22 @@ _ksi_deferred_init() {
|
|||||||
builtin alias edit-in-kitty="kitten edit-in-kitty"
|
builtin alias edit-in-kitty="kitten edit-in-kitty"
|
||||||
|
|
||||||
if (( ! opt[(Ie)no-sudo] )); then
|
if (( ! opt[(Ie)no-sudo] )); then
|
||||||
|
sudo() {
|
||||||
# Ensure terminfo is available in sudo
|
# Ensure terminfo is available in sudo
|
||||||
[[ -n "$TERMINFO" ]] && builtin alias sudo="sudo TERMINFO=\"$TERMINFO\""
|
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 [[ -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
|
# Map alt+left/right to move by word if not already mapped. This is expected behavior on macOS and I am tired
|
||||||
|
|||||||
Reference in New Issue
Block a user