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
|
[[ -z $BUFFER ]] && zle up-history
|
||||||
if [[ $BUFFER == sudo\ * ]]; then
|
if [[ $BUFFER == sudo\ * ]]; then
|
||||||
LBUFFER="${LBUFFER#sudo }"
|
LBUFFER="${LBUFFER#sudo }"
|
||||||
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]]; then
|
elif [[ $BUFFER == $EDITOR\ * ]] || [[ $BUFFER == vi\ * ]] || [[ $BUFFER == vim\ * ]]; then
|
||||||
LBUFFER="${LBUFFER#$EDITOR }"
|
LBUFFER="s$LBUFFER"
|
||||||
LBUFFER="${LBUFFER#vi }"
|
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]|| [[ $BUFFER == svim\ * ]]; then
|
||||||
LBUFFER="svi $LBUFFER"
|
|
||||||
elif [[ $BUFFER == sudoedit\ * ]] || [[ $BUFFER == svi\ * ]]; then
|
|
||||||
LBUFFER="${LBUFFER#sudoedit }"
|
LBUFFER="${LBUFFER#sudoedit }"
|
||||||
LBUFFER="${LBUFFER#svi }"
|
LBUFFER="${LBUFFER#s}"
|
||||||
LBUFFER="$EDITOR $LBUFFER"
|
|
||||||
else
|
else
|
||||||
LBUFFER="sudo $LBUFFER"
|
LBUFFER="sudo $LBUFFER"
|
||||||
fi
|
fi
|
||||||
|
1
aliases
1
aliases
@ -40,6 +40,7 @@ alias -g CLIP="| xclip -i -selection primary -f | xclip -i -selection clipboard"
|
|||||||
calc() { bc -l <<< "$@"; }
|
calc() { bc -l <<< "$@"; }
|
||||||
|
|
||||||
alias svi=sudoedit
|
alias svi=sudoedit
|
||||||
|
alias svim=sudoedit
|
||||||
# This will enable us to use aliases in sudo.
|
# 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.)
|
# (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
|
# Source: https://github.com/mayah/home/blob/master/.zsh/zshrc.d/alias.zsh
|
||||||
|
Loading…
Reference in New Issue
Block a user