Skip to content

Commit

Permalink
.functions: Remove calc
Browse files Browse the repository at this point in the history
Instead, @alrra’s upstream version should be used.

https://github.com/alrra/dotfiles/blob/2133bfed5d8bd2544cb3554e49657979acbb0c2f/src/shell/bash_functions#L5-L31

Hopefully it can be released as a standalone script, installable through brew or npm.

Closes mathiasbynens#703.
  • Loading branch information
mathiasbynens committed Sep 26, 2016
1 parent cd3d3e7 commit a0324e7
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions .functions
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
#!/usr/bin/env bash

# Simple calculator
function calc() {
local result="";
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')";
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
-e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
-e 's/0*$//;s/\.$//'; # remove trailing zeros
else
printf "$result";
fi;
printf "\n";
}

# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
Expand Down

0 comments on commit a0324e7

Please sign in to comment.