[zsh] add currency converter function

legacy
Simon Bruder 2019-05-27 19:34:50 +00:00
parent 31987983c2
commit 737a92fb02
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
1 changed files with 10 additions and 0 deletions

View File

@ -138,6 +138,16 @@ function wp() {
)
}
function currency() {
(
amount=${1:-1}
fromcurrency=${2:-USD}
tocurrency=${3:-EUR}
rate=$(curl -s "https://api.exchangeratesapi.io/latest?base=$fromcurrency&symbols=$tocurrency"|jq ".rates.$tocurrency")
printf "$amount $fromcurrency: %.02f $tocurrency\n" $(($amount * $rate))
)
}
# Program aliases/env
## Aliases for programs