573830ba375ba9c76f6c5ea4edf04b0a0ae3fe34
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #1947 from dongweiming/add-sudo
Add sudo plugin
Diff
1diff --git a/plugins/sudo/sudo.zsh b/plugins/sudo/sudo.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..d12e068530e70ca2dc8e55d21e628214ecadbf29
4--- /dev/null
5+++ b/plugins/sudo/sudo.zsh
6@@ -0,0 +1,22 @@
7+# ------------------------------------------------------------------------------
8+# Description
9+# -----------
10+#
11+# sudo will be inserted before the command
12+#
13+# ------------------------------------------------------------------------------
14+# Authors
15+# -------
16+#
17+# * Dongweiming <ciici123@gmail.com>
18+#
19+# ------------------------------------------------------------------------------
20+
21+sudo-command-line() {
22+[[ -z $BUFFER ]] && zle up-history
23+[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
24+zle end-of-line
25+}
26+zle -N sudo-command-line
27+# Defined shortcut keys: [Esc] [Esc]
28+bindkey "\e\e" sudo-command-line