From 737a92fb0233f7653b63ccd82884bc8c2065ddf4 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Mon, 27 May 2019 19:34:50 +0000 Subject: [PATCH] [zsh] add currency converter function --- home/.zshrc.local | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/home/.zshrc.local b/home/.zshrc.local index 4d47f9e..71bfa23 100644 --- a/home/.zshrc.local +++ b/home/.zshrc.local @@ -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