diff options
Diffstat (limited to 'plugins/sudo/sudo.plugin.zsh')
-rw-r--r-- | plugins/sudo/sudo.plugin.zsh | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e3ba39918..f405b025f 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -2,7 +2,7 @@ # Description # ----------- # -# sudo will be inserted before the command +# sudo or sudoedit will be inserted before the command # # ------------------------------------------------------------------------------ # Authors @@ -14,8 +14,20 @@ sudo-command-line() { [[ -z $BUFFER ]] && zle up-history - [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" + if [[ $BUFFER == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + elif [[ $BUFFER == $EDITOR\ * ]]; then + LBUFFER="${LBUFFER#$EDITOR }" + LBUFFER="sudoedit $LBUFFER" + elif [[ $BUFFER == sudoedit\ * ]]; then + LBUFFER="${LBUFFER#sudoedit }" + LBUFFER="$EDITOR $LBUFFER" + else + LBUFFER="sudo $LBUFFER" + fi } zle -N sudo-command-line # Defined shortcut keys: [Esc] [Esc] -bindkey "\e\e" sudo-command-line +bindkey -M emacs '\e\e' sudo-command-line +bindkey -M vicmd '\e\e' sudo-command-line +bindkey -M viins '\e\e' sudo-command-line |