mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
zsh: improve <ESC><ESC> sudo action with vim
This commit is contained in:
parent
815da41076
commit
7f8c8eccb3
@ -4,14 +4,11 @@ sudo-command-line() {
|
||||
[[ -z $BUFFER ]] && zle up-history
|
||||
if [[ $BUFFER == sudo\ * ]]; then
|
||||
LBUFFER="${LBUFFER#sudo }"
|
||||
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]]; then
|
||||
LBUFFER="${LBUFFER#$EDITOR }"
|
||||
LBUFFER="${LBUFFER#vi }"
|
||||
LBUFFER="svi $LBUFFER"
|
||||
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]; then
|
||||
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]] || [[ $BUFFER == vim\ * ]]; then
|
||||
LBUFFER="s$LBUFFER"
|
||||
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]|| [[ $BUFFER == svim\ * ]]; then
|
||||
LBUFFER="${LBUFFER#sudoedit }"
|
||||
LBUFFER="${LBUFFER#svi }"
|
||||
LBUFFER="$EDITOR $LBUFFER"
|
||||
LBUFFER="${LBUFFER#s}"
|
||||
else
|
||||
LBUFFER="sudo $LBUFFER"
|
||||
fi
|
||||
|
1
aliases
1
aliases
@ -40,6 +40,7 @@ alias -g CLIP="| xclip -i -selection primary -f | xclip -i -selection clipboard"
|
||||
calc() { bc -l <<< "$@"; }
|
||||
|
||||
alias svi=sudoedit
|
||||
alias svim=sudoedit
|
||||
# This will enable us to use aliases in sudo.
|
||||
# (If alias finishes with a space or tab, the shell will check if the next command is also aliased.)
|
||||
# Source: https://github.com/mayah/home/blob/master/.zsh/zshrc.d/alias.zsh
|
||||
|
Loading…
Reference in New Issue
Block a user