From 639c7a456dfb4b60c4cccec9aab03fdcc11416f5 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 28 Nov 2024 14:16:10 +0300 Subject: [PATCH] zsh refactor --- home/user/.config/zsh/mappings | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/home/user/.config/zsh/mappings b/home/user/.config/zsh/mappings index 99c7267..11286e0 100644 --- a/home/user/.config/zsh/mappings +++ b/home/user/.config/zsh/mappings @@ -29,7 +29,12 @@ insert-sudo() { if [ -z "${LBUFFER}${RBUFFER}" ]; then zle up-history + if [ ! "${LBUFFER::$template_len}" = "$sudo_template" ]; then + LBUFFER="${sudo_template}${LBUFFER}" + fi + return fi + if [ "${LBUFFER::$template_len}" = "$sudo_template" ]; then LBUFFER="${LBUFFER:$template_len}" else @@ -79,14 +84,15 @@ bindkey -M vicmd "^O" cddotdot accept-line-or-list-dir() { - if [ -z "${LBUFFER}${RBUFFER}" ]; then - echo - ls - echo - zle reset-prompt - else + if [ -n "${LBUFFER}${RBUFFER}" ]; then zle .accept-line + return fi + + echo + ls + echo + zle reset-prompt } zle -N accept-line-or-list-dir