[zsh] add currency converter function
This commit is contained in:
parent
31987983c2
commit
737a92fb02
|
@ -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
|
||||
|
|
Reference in a new issue