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
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
elif [[ $BUFFER == $EDITOR\ * ]]; then
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]]; then
LBUFFER="${LBUFFER#$EDITOR }"
LBUFFER="sudoedit $LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]]; then
LBUFFER="${LBUFFER#vi }"
LBUFFER="svi $LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]; then
LBUFFER="${LBUFFER#sudoedit }"
LBUFFER="${LBUFFER#svi }"
LBUFFER="$EDITOR $LBUFFER"
else
LBUFFER="sudo $LBUFFER"