fix zsh inline calculator

This commit is contained in:
thek4n 2024-11-29 15:25:21 +03:00
parent baa87509da
commit 3f0fdef139
2 changed files with 9 additions and 22 deletions

View File

@ -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

View File

@ -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
bindkey -M vicmd "^O" cddotdot