#! /bin/zsh # # this file: # http://user.it.uu.se/~embe8573/conf/.zsh/money # https://dataswamp.org/~incal/conf/.zsh/money # # zsh CLI to Internet inflation calculator # # Try, for example, three K2 expeditions: # # $ inflation 9000 1938; inflation 30958.33 1953; inflation 108000 1954 # $151,999.15 # $276,111.20 # $956,069.00 # # Note: Doesn't work anymore. # # inflation () { # local url="http://data.bls.gov/cgi-bin/cpicalc.pl" # curl -s \ # -d cost1=${1:-10} \ # -d year1=${2:-1950} \ # -d year2=$(date +%Y) $url | # awk '/"answer"/' | # tr -d -c '$0-9.,\n' # } #### X <-> Y # http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Simple-Bash-Currency-Converter # cconv () { # local amount=$1 # local from=$2 # local to=$3 # # local url="http://finance.google.com/finance/converter?a=$amount&from=$from&to=$to" # wget $url -q -O - | sed '/res/!d;s/<[^>]*>//g' | awk '{print $4}' # } # # money-from-to () { # local amount=$1 # local from=${2:u} # local to=${3:u} # # local converted_amount=$(( rint($(cconv $amount $from $to)) )) # printf "%d %s ~= %d %s\n" $amount $from $converted_amount $to # } ### X <-> SEK # X -> SEK # money-to-sek () { # local amount=$1 # local from=${2:u} # money-from-to $amount $from SEK # } # alias to-sek=money-to-sek # # usd-to-sek () { # local usd=$1 # money-from-to $usd usd SEK # } # alias usd=usd-to-sek # SEK -> USD, GBP & EUR # money-from-sek () { # local sek=$1 # local usd=$(( $(cconv $sek sek usd) )) # local gbp=$(( $(cconv $sek sek gbp) )) # local eur=$(( $(cconv $sek sek eur) )) # printf "%.2f SEK ~= \$%.2f | \ua3%.2f | \u20ac%.2f\n" $sek $usd $gbp $eur # } # alias sek=money-from-sek