From 3f0fdef139ac78ad91189e6224fa74271ccbaba0 Mon Sep 17 00:00:00 2001 From: thek4n Date: Fri, 29 Nov 2024 15:25:21 +0300 Subject: [PATCH] fix zsh inline calculator --- home/user/.config/zsh/calculator | 12 ++++++++---- home/user/.config/zsh/mappings | 19 +------------------ 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/home/user/.config/zsh/calculator b/home/user/.config/zsh/calculator index 36e29e5..0c25578 100644 --- a/home/user/.config/zsh/calculator +++ b/home/user/.config/zsh/calculator @@ -12,13 +12,17 @@ aliases[=]='noglob __calc' function accept-line() { - if [[ $BUFFER =~ '^[ ]?\(?[-+]?[0-9]+[^a-zA-Z]+' ]]; then + if [[ -z "${BUFFER}" ]]; then echo - test "$BUFFER[1]" != " " && print -S -- "$BUFFER" # saving the command to history - __calc "$BUFFER" | sed 's/\.$//' + ls + elif [[ ${BUFFER} =~ '^[ ]?\(?[-+]?[0-9]+[^a-zA-Z]+' ]]; then + echo + test "${BUFFER[1]}" != " " && print -S -- "${BUFFER}" # saving the command to history + __calc "${BUFFER}" | sed 's/\.$//' BUFFER= fi - zle .$WIDGET + + zle .${WIDGET} } zle -N accept-line diff --git a/home/user/.config/zsh/mappings b/home/user/.config/zsh/mappings index 11286e0..2147a42 100644 --- a/home/user/.config/zsh/mappings +++ b/home/user/.config/zsh/mappings @@ -80,21 +80,4 @@ cddotdot() { } zle -N cddotdot bindkey "^O" cddotdot -bindkey -M vicmd "^O" cddotdot - - -accept-line-or-list-dir() { - if [ -n "${LBUFFER}${RBUFFER}" ]; then - zle .accept-line - return - fi - - echo - ls - echo - zle reset-prompt -} - -zle -N accept-line-or-list-dir -bindkey "^M" accept-line-or-list-dir -bindkey -M vicmd "^M" accept-line-or-list-dir \ No newline at end of file +bindkey -M vicmd "^O" cddotdot \ No newline at end of file