summaryrefslogtreecommitdiff
path: root/plugins/sudo/sudo.zsh
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2013-12-02 23:40:12 -0800
committerRobby Russell <robby@planetargon.com>2013-12-02 23:40:12 -0800
commit573830ba375ba9c76f6c5ea4edf04b0a0ae3fe34 (patch)
tree380cef559eab58447fbbfd15df603d1b57a9e33c /plugins/sudo/sudo.zsh
parent2f3bddccfb4daac3dbaa7be2dd19fb6aaa7f09ce (diff)
parent744f3654e2bfb4806381ca4f0a5dfcfa5b1c3b83 (diff)
downloadzsh-573830ba375ba9c76f6c5ea4edf04b0a0ae3fe34.tar.gz
zsh-573830ba375ba9c76f6c5ea4edf04b0a0ae3fe34.tar.bz2
zsh-573830ba375ba9c76f6c5ea4edf04b0a0ae3fe34.zip
Merge pull request #1947 from dongweiming/add-sudo
Add sudo plugin
Diffstat (limited to 'plugins/sudo/sudo.zsh')
-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