summaryrefslogtreecommitdiff
path: root/plugins/sudo/sudo.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/sudo/sudo.plugin.zsh')
-rw-r--r--plugins/sudo/sudo.plugin.zsh25
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
new file mode 100644
index 000000000..0ba8bed5b
--- /dev/null
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -0,0 +1,25 @@
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# sudo will be inserted before the command
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Dongweiming <ciici123@gmail.com>
+#
+# ------------------------------------------------------------------------------
+
+sudo-command-line() {
+ [[ -z $BUFFER ]] && zle up-history
+ if [[ $BUFFER == sudo\ * ]]; then
+ LBUFFER="${LBUFFER#sudo }"
+ else
+ LBUFFER="sudo $LBUFFER"
+ fi
+}
+zle -N sudo-command-line
+# Defined shortcut keys: [Esc] [Esc]
+bindkey "\e\e" sudo-command-line