mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-13 03:12:21 +01:00
Merge 714091279f into 13e5afe805
This commit is contained in:
commit
29cdd0889d
1 changed files with 13 additions and 4 deletions
|
|
@ -2,20 +2,29 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# sudo will be inserted before the command
|
# sudo will be inserted before the command and the cursor position will be
|
||||||
|
# preserved. If the prompt is empty, the previously executed command will be
|
||||||
|
# fetched from the history and prepended with "sudo ".
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
# -------
|
# -------
|
||||||
#
|
#
|
||||||
# * Dongweiming <ciici123@gmail.com>
|
# * Dongweiming <ciici123@gmail.com>
|
||||||
|
# * Michael Fladischer <FladischerMichael@fladi.at>
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sudo_preserve_cursor=1
|
||||||
|
|
||||||
sudo-command-line() {
|
sudo-command-line() {
|
||||||
[[ -z $BUFFER ]] && zle up-history
|
[[ -z $BUFFER ]] && zle up-history
|
||||||
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
|
if [[ $sudo_preserve_cursor -eq 1 ]]; then
|
||||||
zle end-of-line
|
[[ $LBUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
|
||||||
|
else
|
||||||
|
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
|
||||||
|
zle end-of-line
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
zle -N sudo-command-line
|
zle -N sudo-command-line
|
||||||
# Defined shortcut keys: [Esc] [Esc]
|
# Defined shortcut keys: [Esc] [Esc]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue