diff --git a/plugins/sudo/sudo.zsh b/plugins/sudo/sudo.zsh new file mode 100644 index 000000000..d12e06853 --- /dev/null +++ b/plugins/sudo/sudo.zsh @@ -0,0 +1,22 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# sudo will be inserted before the command +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Dongweiming +# +# ------------------------------------------------------------------------------ + +sudo-command-line() { +[[ -z $BUFFER ]] && zle up-history +[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" +zle end-of-line +} +zle -N sudo-command-line +# Defined shortcut keys: [Esc] [Esc] +bindkey "\e\e" sudo-command-line