summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordongweiming <ciici123@hotmail.com>2013-07-04 19:18:52 +0800
committerdongweiming <ciici123@hotmail.com>2013-07-04 19:18:52 +0800
commit744f3654e2bfb4806381ca4f0a5dfcfa5b1c3b83 (patch)
treeb02e8879e3833300d129f728693d27a24807c2a5 /plugins
parentbc3cadf5c83697c176c9d4ce41c7fde7f57bf6e7 (diff)
downloadzsh-744f3654e2bfb4806381ca4f0a5dfcfa5b1c3b83.tar.gz
zsh-744f3654e2bfb4806381ca4f0a5dfcfa5b1c3b83.tar.bz2
zsh-744f3654e2bfb4806381ca4f0a5dfcfa5b1c3b83.zip
Add sudo plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sudo/sudo.zsh22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/sudo/sudo.zsh b/plugins/sudo/sudo.zsh
new file mode 100644
index 000000000..d12e06853
--- /dev/null
+++ b/plugins/sudo/sudo.zsh
@@ -0,0 +1,22 @@
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# sudo will be inserted before the command
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Dongweiming <ciici123@gmail.com>
+#
+# ------------------------------------------------------------------------------
+
+sudo-command-line() {
+[[ -z $BUFFER ]] && zle up-history
+[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
+zle end-of-line
+}
+zle -N sudo-command-line
+# Defined shortcut keys: [Esc] [Esc]
+bindkey "\e\e" sudo-command-line