Plugin to toggle sudo before your current or last command

pull/1557/head
Uco Mesdag 2020-04-13 02:30:28 +02:00
parent f2c07f5143
commit b220c0e744
No known key found for this signature in database
GPG Key ID: 4ADCB4FA8FCAAA19
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
cite about-plugin
about-plugin 'Toggle sudo before your current or last command'
function sudo-command-line() {
[[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs)
if [[ $READLINE_LINE == sudo\ * ]]; then
READLINE_LINE="${READLINE_LINE#sudo }"
else
READLINE_LINE="sudo $READLINE_LINE"
fi
READLINE_POINT=${#READLINE_LINE}
}
# Define shortcut keys: [Esc] [Esc]
bind -x '"\e\e": sudo-command-line'