2021-07-08 16:29:42 +00:00
|
|
|
#
|
2019-10-31 23:18:00 +00:00
|
|
|
# sudo will be inserted before the current command
|
2021-07-08 16:29:42 +00:00
|
|
|
#
|
|
|
|
|
2019-10-31 23:18:00 +00:00
|
|
|
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
|