From 568f7903ca7464f99df659b8488bd731e4f2c4f0 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 20 Dec 2020 16:49:47 +0530 Subject: Adds zsh config --- external/zsh/plugins/sudo.zsh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 external/zsh/plugins/sudo.zsh (limited to 'external/zsh/plugins/sudo.zsh') diff --git a/external/zsh/plugins/sudo.zsh b/external/zsh/plugins/sudo.zsh new file mode 100644 index 0000000..fd43b93 --- /dev/null +++ b/external/zsh/plugins/sudo.zsh @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# sudo or sudoedit will be inserted before the command +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Dongweiming +# +# ------------------------------------------------------------------------------ + +MAGIC_ENTER_GIT_COMMAND='git status'; +MAGIC_ENTER_OTHER_COMMAND='ls'; + +sudo-command-line() { + [[ -z $BUFFER ]] && zle up-history + if [[ $BUFFER == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + elif [[ $BUFFER == $EDITOR\ * ]]; then + LBUFFER="${LBUFFER#$EDITOR }" + LBUFFER="sudoedit $LBUFFER" + elif [[ $BUFFER == sudoedit\ * ]]; then + LBUFFER="${LBUFFER#sudoedit }" + LBUFFER="$EDITOR $LBUFFER" + else + LBUFFER="sudo $LBUFFER" + fi +} + +zle -N sudo-command-line; +bindkey '^Z' sudo-command-line; + -- cgit v1.3.1