Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
fd9781b4
Unverified
Commit
fd9781b4
authored
Jul 06, 2020
by
MDHD
Committed by
GitHub
Jul 06, 2020
Browse files
sudo: make the behavior more in line with expectations (#9047)
parent
a8fee403
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/sudo/sudo.plugin.zsh
View file @
fd9781b4
...
@@ -13,15 +13,28 @@
...
@@ -13,15 +13,28 @@
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
sudo-command-line
()
{
sudo-command-line
()
{
[[
-z
$BUFFER
]]
&&
zle up-history
[[
-z
$BUFFER
]]
&&
LBUFFER
=
"
$(
fc
-ln
-1
)
"
if
[[
$BUFFER
==
sudo
\
*
]]
;
then
if
[[
-n
$EDITOR
&&
$BUFFER
==
$EDITOR
\
*
]]
;
then
LBUFFER
=
"
${
LBUFFER
#sudo
}
"
if
[[
${#
LBUFFER
}
-le
${#
EDITOR
}
]]
;
then
elif
[[
$BUFFER
==
$EDITOR
\
*
]]
;
then
RBUFFER
=
"
${
BUFFER
#
$EDITOR
}
"
LBUFFER
=
"
${
LBUFFER
#
$EDITOR
}
"
LBUFFER
=
"sudoedit"
LBUFFER
=
"sudoedit
$LBUFFER
"
else
LBUFFER
=
"sudoedit
${
LBUFFER
#
$EDITOR
}
"
fi
elif
[[
$BUFFER
==
sudoedit
\
*
]]
;
then
elif
[[
$BUFFER
==
sudoedit
\
*
]]
;
then
LBUFFER
=
"
${
LBUFFER
#sudoedit
}
"
if
[[
${#
LBUFFER
}
-le
8
]]
;
then
LBUFFER
=
"
$EDITOR
$LBUFFER
"
RBUFFER
=
"
${
BUFFER
#sudoedit
}
"
LBUFFER
=
"
$EDITOR
"
else
LBUFFER
=
"
$EDITOR
${
LBUFFER
#sudoedit
}
"
fi
elif
[[
$BUFFER
==
sudo
\
*
]]
;
then
if
[[
${#
LBUFFER
}
-le
4
]]
;
then
RBUFFER
=
"
${
BUFFER
#sudo
}
"
LBUFFER
=
""
else
LBUFFER
=
"
${
LBUFFER
#sudo
}
"
fi
else
else
LBUFFER
=
"sudo
$LBUFFER
"
LBUFFER
=
"sudo
$LBUFFER
"
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment