From fc232c4f80361b763a19134716a1e9a7ce538590 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 28 Nov 2024 10:16:02 +0300 Subject: [PATCH] feat: zsh: add mappings for fast git status and list directory --- home/user/.config/zsh/mappings | 44 ++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/home/user/.config/zsh/mappings b/home/user/.config/zsh/mappings index ad00796..779fedd 100644 --- a/home/user/.config/zsh/mappings +++ b/home/user/.config/zsh/mappings @@ -1,3 +1,5 @@ +# vim: ft=zsh + KEYTIMEOUT=1 # Activate vim mode. bindkey -v @@ -22,17 +24,17 @@ bindkey '^[[Z' reverse-menu-complete # S-Tab insert-sudo() { - local sudo_template="${SUDO:=sudo} " - local template_len="${#sudo_template}" + local sudo_template="${SUDO:=sudo} " + local template_len="${#sudo_template}" - if [ -z "${LBUFFER}${RBUFFER}" ]; then - zle up-history - fi - if [ "${LBUFFER::$template_len}" = "$sudo_template" ]; then - LBUFFER="${LBUFFER:$template_len}" - else - LBUFFER="${sudo_template}${LBUFFER}" - fi + if [ -z "${LBUFFER}${RBUFFER}" ]; then + zle up-history + fi + if [ "${LBUFFER::$template_len}" = "$sudo_template" ]; then + LBUFFER="${LBUFFER:$template_len}" + else + LBUFFER="${sudo_template}${LBUFFER}" + fi } zle -N insert-sudo @@ -47,6 +49,28 @@ bindkey '^W' backward-delete-word bindkey -M vicmd '^H' backward-delete-char +listdirquiet() { + echo + ls + echo + zle reset-prompt +} +zle -N listdirquiet +bindkey "^L" listdirquiet +bindkey -M vicmd "^L" listdirquiet + + +gitstatusquiet() { + echo + git status + echo + zle reset-prompt +} +zle -N gitstatusquiet +bindkey "^N" gitstatusquiet +bindkey -M vicmd "^N" gitstatusquiet + + popdquiet() { popd &>/dev/null zle reset-prompt