summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.zsh/functions/insert-sudo5
-rw-r--r--.zshrc2
2 files changed, 7 insertions, 0 deletions
diff --git a/.zsh/functions/insert-sudo b/.zsh/functions/insert-sudo
new file mode 100644
index 0000000..4fc68e6
--- /dev/null
+++ b/.zsh/functions/insert-sudo
@@ -0,0 +1,5 @@
+# -*- mode: sh; -*-
+# Copied and modified from
+# http://zshwiki.org/home/code/zle/addsudoorpfexec
+BUFFER="sudo $(history -n -1 -1)"
+CURSOR=$#BUFFER
diff --git a/.zshrc b/.zshrc
index 1d6f045..959b130 100644
--- a/.zshrc
+++ b/.zshrc
@@ -75,6 +75,7 @@ export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
zle -N emacs-backward-kill-word
+zle -N insert-sudo
# Set terminal keys
bindkey "\e[1~" beginning-of-line
@@ -101,6 +102,7 @@ bindkey "\e[F" end-of-line
bindkey "^W" backward-delete-char
bindkey "^\b" emacs-backward-kill-word
+bindkey "^[#" insert-sudo
source /usr/share/zsh/scripts/antigen/antigen.zsh
antigen bundle zsh-users/zsh-syntax-highlighting