Added function metadata and bash version check

pull/1557/head
Uco Mesdag 2020-04-13 13:35:52 +02:00
parent e73f6dbc62
commit dfeb72d6aa
No known key found for this signature in database
GPG Key ID: 4ADCB4FA8FCAAA19
1 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,10 @@
cite about-plugin
about-plugin 'Toggle sudo at the beginning of the current or the previous command'
about-plugin 'Toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice'
function sudo-command-line() {
about "toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice"
group "sudo"
[[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs)
if [[ $READLINE_LINE == sudo\ * ]]; then
READLINE_LINE="${READLINE_LINE#sudo }"
@ -12,4 +15,8 @@ function sudo-command-line() {
}
# Define shortcut keys: [Esc] [Esc]
# Readline library requires bash version 4 or later
if [ "${BASH_VERSINFO}" -ge 4 ]; then
bind -x '"\e\e": sudo-command-line'
fi