feat(zsh): inline calculator

This commit is contained in:
thek4n 2024-05-23 16:34:44 +03:00
parent 048eb314e6
commit a69fd53fc3

View File

@ -7,4 +7,17 @@ function __calc {
aliases[calc]='noglob __calc' aliases[calc]='noglob __calc'
aliases[=]='noglob __calc' aliases[=]='noglob __calc'
function accept-line() {
if [[ $BUFFER =~ '^[ ]?\(?[-+]?[0-9]+' ]]; then
echo
test "$BUFFER[1]" != " " && print -S -- "$BUFFER" # saving the command to history
__calc "$BUFFER"
BUFFER=
fi
zle .$WIDGET
}
zle -N accept-line
# vim: ft=zsh # vim: ft=zsh