From ff8d799594d0fd127058455b194b27d00a323d68 Mon Sep 17 00:00:00 2001 From: Fabio Strozzi Date: Sun, 12 Jul 2015 17:01:34 +0200 Subject: [PATCH] Esc-esc now toggles sudo. Press esc-esc once to add sudo (normal behaviour), press it twice to remove it from the beginning of the line. --- plugins/sudo/sudo.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e3ba39918..0ba8bed5b 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -14,7 +14,11 @@ sudo-command-line() { [[ -z $BUFFER ]] && zle up-history - [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" + if [[ $BUFFER == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + else + LBUFFER="sudo $LBUFFER" + fi } zle -N sudo-command-line # Defined shortcut keys: [Esc] [Esc]