From adc5c29e1edb79b055b080192d608fd334c63238 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 8 Jan 2022 23:09:29 +0100 Subject: [PATCH] bin/=: improve calculation utility --- .config/shell/functions | 3 ++- .local/bin/scripts/= | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index 95e030b..bab085d 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -167,6 +167,7 @@ alias jcj='jcl -o json-pretty -u' alias v='edit' alias st='synct' alias expr='noglob expr' +alias get='noglob =' alias kc='kdeconnect-cli --refresh && kdeconnect-cli --list-devices' # Shortcuts @@ -196,7 +197,7 @@ sshl() { 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" TERM=xterm-256color kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@" - else ssh "$@" + else TERM=xterm-256color ssh "$@" fi } diff --git a/.local/bin/scripts/= b/.local/bin/scripts/= index 713f38c..6554a52 100755 --- a/.local/bin/scripts/= +++ b/.local/bin/scripts/= @@ -1,7 +1,5 @@ #!/bin/sh -IFS=' ' -calc="${*//p/+}" -calc="${calc//./}" -calc="${calc//,/.}" -calc="${calc//x/*}" -bc -l <<<"scale=10;$calc" +# Shortcut for mathematical calculations +# Assumes german numbers as in 1.000,5 +calc="$(echo "$@" | sed -e 's/p/+/g' -e 's/\.//g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')" +bc -l <<<"scale=10;$calc" | sed 's/0\+$/0/'