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
Oh My Zsh
Commits
cd17aed9
Unverified
Commit
cd17aed9
authored
Aug 23, 2020
by
daddeffe
Committed by
GitHub
Aug 23, 2020
Browse files
sudo: keep space before the command to ignore it in the history (#9178)
Co-authored-by:
Marc Cornellà
<
marc.cornella@live.com
>
parent
c785db62
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/sudo/sudo.plugin.zsh
View file @
cd17aed9
...
@@ -14,6 +14,14 @@
...
@@ -14,6 +14,14 @@
sudo-command-line
()
{
sudo-command-line
()
{
[[
-z
$BUFFER
]]
&&
LBUFFER
=
"
$(
fc
-ln
-1
)
"
[[
-z
$BUFFER
]]
&&
LBUFFER
=
"
$(
fc
-ln
-1
)
"
# Save beginning space
local
WHITESPACE
=
""
if
[[
${
LBUFFER
:0:1
}
==
" "
]]
;
then
WHITESPACE
=
" "
LBUFFER
=
"
${
LBUFFER
:1
}
"
fi
if
[[
-n
$EDITOR
&&
$BUFFER
==
$EDITOR
\
*
]]
;
then
if
[[
-n
$EDITOR
&&
$BUFFER
==
$EDITOR
\
*
]]
;
then
if
[[
${#
LBUFFER
}
-le
${#
EDITOR
}
]]
;
then
if
[[
${#
LBUFFER
}
-le
${#
EDITOR
}
]]
;
then
RBUFFER
=
"
${
BUFFER
#
$EDITOR
}
"
RBUFFER
=
"
${
BUFFER
#
$EDITOR
}
"
...
@@ -38,6 +46,9 @@ sudo-command-line() {
...
@@ -38,6 +46,9 @@ sudo-command-line() {
else
else
LBUFFER
=
"sudo
$LBUFFER
"
LBUFFER
=
"sudo
$LBUFFER
"
fi
fi
# Preserve beginning space
LBUFFER
=
"
${
WHITESPACE
}${
LBUFFER
}
"
}
}
zle
-N
sudo-command-line
zle
-N
sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
# Defined shortcut keys: [Esc] [Esc]
...
...
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