[ESC ESC] - insert sudo in the Begining of line

This commit is contained in:
philosophos 2017-03-16 12:14:27 +08:00
commit 791a926bc5

View file

@ -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