1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00
dotfiles/zsh/plugins/sudo.zsh
Joe Groocock 60bf423556
dotfiles: move .config/* to root
This seems to make more sense. Almost all files were within .config
anyway.

Signed-off-by: Joe Groocock <me@frebib.net>
2020-08-10 22:42:14 +01:00

21 lines
685 B
Bash

# Source: https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/sudo/sudo.plugin.zsh
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]] || [[ $BUFFER == vim\ * ]]; then
LBUFFER="s$LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]|| [[ $BUFFER == svim\ * ]]; then
LBUFFER="${LBUFFER#sudoedit }"
LBUFFER="${LBUFFER#s}"
else
LBUFFER="sudo $LBUFFER"
fi
_zsh_highlight
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" sudo-command-line