zsh-grawlinson/plugins/sudo
George Rawlinson 51e5d74b70
fix: simplify sudo plugin
sudoedit isn't available on all systems.
sometimes we don't want to use $EDITOR. or it is not set.
2021-07-08 16:29:42 +00:00

19 lines
368 B
Bash

#
# sudo will be inserted before the current command
#
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
else
LBUFFER="sudo $LBUFFER"
fi
}
zle -N sudo-command-line
# defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" sudo-command-line
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2