1
0
Fork 0
mirror of synced 2024-11-16 13:05:35 -05:00
This commit is contained in:
Alex 2017-04-24 19:03:22 +00:00 committed by GitHub
commit 07d469aecc

View file

@ -120,3 +120,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!" prepend-sudoas