Skip to content

Commit

Permalink
zshrc: change sudo-command-line switch 'sudo'
Browse files Browse the repository at this point in the history
fix add 'sudo' plugin zsh-syntax-highlighting error
  • Loading branch information
a-wing committed May 17, 2021
1 parent 03190b2 commit e7927a8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions etc/zsh/zshrc
Expand Up @@ -1200,10 +1200,15 @@ zle -N grml-zsh-fg
# run command line as user root via sudo:
function sudo-command-line () {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER != sudo\ * ]]; then
BUFFER="sudo $BUFFER"
CURSOR=$(( CURSOR+5 ))
local cmd="sudo "
if [[ ${BUFFER:0:${#cmd}} == ${cmd} ]]; then
CURSOR=$(( CURSOR-${#cmd} ))
BUFFER="${BUFFER:${#cmd}}"
else
BUFFER="${cmd}${BUFFER}"
CURSOR=$(( CURSOR+${#cmd} ))
fi
zle reset-prompt
}
zle -N sudo-command-line

Expand Down

0 comments on commit e7927a8

Please sign in to comment.