1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Customise sudo plugin to fit my aliases

This commit is contained in:
Joe Groocock 2017-11-16 00:30:45 +00:00
parent da62525a0b
commit 878b13b2fa
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86

View File

@ -4,11 +4,13 @@ sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history [[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }" LBUFFER="${LBUFFER#sudo }"
elif [[ $BUFFER == $EDITOR\ * ]]; then elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]]; then
LBUFFER="${LBUFFER#$EDITOR }" LBUFFER="${LBUFFER#$EDITOR }"
LBUFFER="sudoedit $LBUFFER" LBUFFER="${LBUFFER#vi }"
elif [[ $BUFFER == sudoedit\ * ]]; then LBUFFER="svi $LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]; then
LBUFFER="${LBUFFER#sudoedit }" LBUFFER="${LBUFFER#sudoedit }"
LBUFFER="${LBUFFER#svi }"
LBUFFER="$EDITOR $LBUFFER" LBUFFER="$EDITOR $LBUFFER"
else else
LBUFFER="sudo $LBUFFER" LBUFFER="sudo $LBUFFER"