1
0
Fork 0
mirror of synced 2024-12-24 23:13:21 -05:00

Added doas-sudo - inserts doas or sudo before current command

This commit is contained in:
Alex Poslavsky 2016-05-21 15:49:43 +03:00
parent 7439df5836
commit e7f42cc6ba

View file

@ -118,3 +118,20 @@ fi
mkcd() {
[[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1}
}
# Inserts 'doas ' or 'sudo ' at the beginning of a line.
function prepend-sudoas {
if [[ "$BUFFER" != (doas|su(do|))\ * ]]; then
if [[ $OSTYPE == openbsd* ]]; then
BUFFER="doas $BUFFER"
else
BUFFER="sudo $BUFFER"
fi
(( CURSOR += 5 ))
fi
}
zle -N prepend-sudoas
# Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" prepend-sudoas