From 791a926bc5fb99950682ddc3ac410dcad6d67a4d Mon Sep 17 00:00:00 2001 From: philosophos Date: Thu, 16 Mar 2017 12:14:27 +0800 Subject: [PATCH] [ESC ESC] - insert sudo in the Begining of line --- lib/key-bindings.zsh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 0e056dc72..fd8fdb63d 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -91,3 +91,13 @@ bindkey "^[m" copy-prev-shell-word ## Fix weird sequence that rxvt produces #bindkey -s '^[[Z' '\t' # + +# [ESC ESC] - insert sudo in the Begining of line +sudo-command-line() { + [[ -z $BUFFER ]] && zle up-history + [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" + zle end-of-line +} +zle -N sudo-command-line +bindkey "\e\e" sudo-command-line +