fix: simplify sudo plugin

sudoedit isn't available on all systems.
sometimes we don't want to use $EDITOR. or it is not set.
This commit is contained in:
George Rawlinson 2021-07-08 16:29:42 +00:00
parent 2688ff59a1
commit 51e5d74b70
Signed by: grawlinson
GPG key ID: E0959FEA8B550539

View file

@ -1,14 +1,11 @@
#
# sudo will be inserted before the current command
#
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
elif [[ $BUFFER == $EDITOR\ * ]]; then
LBUFFER="${LBUFFER#$EDITOR }"
LBUFFER="sudoedit $LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]]; then
LBUFFER="${LBUFFER#sudoedit }"
LBUFFER="$EDITOR $LBUFFER"
else
LBUFFER="sudo $LBUFFER"
fi