bin/=: improve calculation utility

This commit is contained in:
xeruf 2022-01-08 23:09:29 +01:00
parent 42e5ad9cb1
commit adc5c29e1e
2 changed files with 6 additions and 7 deletions

View File

@ -167,6 +167,7 @@ alias jcj='jcl -o json-pretty -u'
alias v='edit' alias v='edit'
alias st='synct' alias st='synct'
alias expr='noglob expr' alias expr='noglob expr'
alias get='noglob ='
alias kc='kdeconnect-cli --refresh && kdeconnect-cli --list-devices' alias kc='kdeconnect-cli --refresh && kdeconnect-cli --list-devices'
# Shortcuts # Shortcuts
@ -196,7 +197,7 @@ sshl() {
if test ! -e "$file"; then if test ! -e "$file"; then
ssh-copy-id -i "$(ssh -G "$1" | grep "^identityfile " | head -1 | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1" && touch "$file" ssh-copy-id -i "$(ssh -G "$1" | grep "^identityfile " | head -1 | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1" && touch "$file"
TERM=xterm-256color kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@" TERM=xterm-256color kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@"
else ssh "$@" else TERM=xterm-256color ssh "$@"
fi fi
} }

View File

@ -1,7 +1,5 @@
#!/bin/sh #!/bin/sh
IFS=' ' # Shortcut for mathematical calculations
calc="${*//p/+}" # Assumes german numbers as in 1.000,5
calc="${calc//./}" calc="$(echo "$@" | sed -e 's/p/+/g' -e 's/\.//g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')"
calc="${calc//,/.}" bc -l <<<"scale=10;$calc" | sed 's/0\+$/0/'
calc="${calc//x/*}"
bc -l <<<"scale=10;$calc"