Skip to content

Instantly share code, notes, and snippets.

@ype
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save ype/52b0381a97efbd280b17 to your computer and use it in GitHub Desktop.

Select an option

Save ype/52b0381a97efbd280b17 to your computer and use it in GitHub Desktop.
Ledger ZSH currency convert function
#LEDGER Quick Print Converted Accounts
bal() {
re='^[A-Za-z0-9]+$'
if [[ "$1" == "GBP" ]]
then
perl /usr/local/Cellar/ledger/*/share/ledger/contrib/getquote.pl CAD GBP > ~/.currencydb
elif [[ "$1" == "CAD" ]]
then
perl /usr/local/Cellar/ledger/*/share/ledger/contrib/getquote.pl GBP CAD > ~/.currencydb
else
echo "Not retrieving exchange rates"
fi
if ! [[ -z "$2" ]]
then
ledger "$2" --market="$1" --price-db=~/.currencydb
else
ledger "$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment