summaryrefslogtreecommitdiff
path: root/dot_local/share/toasty/plugins
diff options
context:
space:
mode:
authorChloe Kudryavtsev <toast@toast.cafe>2020-02-14 19:11:04 -0500
committerChloe Kudryavtsev <toast@toast.cafe>2020-02-14 19:11:04 -0500
commit0d9a5a245a7be7e444d7f34e959dd06cb7b053e0 (patch)
tree3d42142e6ee22dbb72683e0b3549216f17bb6629 /dot_local/share/toasty/plugins
parentzsh: remove toasty (preparation for git subtree) (diff)
parentSquashed 'dot_local/share/toasty/' content from commit aee4da7 (diff)
Merge commit '858a4a31a251d0eab21dffb96776aca007dafb07' as 'dot_local/share/toasty'
Diffstat (limited to '')
-rw-r--r--dot_local/share/toasty/plugins/sudo25
-rw-r--r--dot_local/share/toasty/plugins/xterm-title10
2 files changed, 35 insertions, 0 deletions
diff --git a/dot_local/share/toasty/plugins/sudo b/dot_local/share/toasty/plugins/sudo
new file mode 100644
index 0000000..0ba8bed
--- /dev/null
+++ b/dot_local/share/toasty/plugins/sudo
@@ -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
diff --git a/dot_local/share/toasty/plugins/xterm-title b/dot_local/share/toasty/plugins/xterm-title
new file mode 100644
index 0000000..a57ea03
--- /dev/null
+++ b/dot_local/share/toasty/plugins/xterm-title
@@ -0,0 +1,10 @@
+function xterm-title {
+ print -Pn '\e]0;%n@%m $(history $HISTCMD | cut -b8-)\a'
+}
+
+autoload -Uz add-zsh-hook
+add-zsh-hook precmd xterm-title
+add-zsh-hook preexec xterm-title
+add-zsh-hook chpwd xterm-title
+
+# vim: ft=zsh