Skip to content

sebinsua/teller-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

teller-cli Build Status

Banking for your command line

This tool provides useful ways of interrogating your bank through your command line, and is not merely meant to be a one-to-one match with underlying APIs.

It uses Teller behind-the-scenes to interact with your UK bank, so you will need to have an account there.

πŸ‘† Want an account? @stevegraham can hook you up!

Usage

teller show balance current will show you your current account's balance.

teller --help for more commands.

e.g.

Instructions

Why?

Notifications with terminal-notifier

teller show balance current | terminal-notifier -title "Current Account Balance"

Notifications

Alert when πŸ’° low

#!/bin/sh

CURRENT_BALANCE=`teller show balance current --hide-currency`;
MIN_BALANCE=1000.00;

if (( $(bc <<< "$CURRENT_BALANCE < $MIN_BALANCE") ))
then
  echo "Your current balance has fallen below Β£$MIN_BALANCE" | terminal-notifier -title "πŸ’° Alert" -subtitle "Current Balance is Β£$CURRENT_BALANCE";
fi

Alerts

β˜• How much money do I spend at Nanna's?

> teller list transactions current | grep "NANNA'S"
27   2015-11-12  NANNA'S             -2.70
60   2015-10-28  NANNA'S             -2.40
68   2015-10-26  NANNA'S             -5.40
101  2015-10-09  NANNA'S             -2.70
203  2015-07-17  NANNA'S             -4.60
206  2015-07-16  NANNA'S             -9.90
208  2015-07-16  NANNA'S             -9.30
209  2015-07-16  NANNA'S             -0.10

Hopefully Teller will add support for querying transactions soon.

Am I saving money with a chart πŸ“ˆ with spark

> teller list balances business --interval=monthly --timeframe=year --output=spark | spark
β–β–β–β–‚β–ƒβ–‚β–ƒβ–„β–„β–…β–†β–ˆ

Have I spent more money this month than I normally do?

#!/bin/sh

CURRENT_OUTGOING=`teller show outgoing current --hide-currency | sed 's/^-//'`;
OUTGOINGS=`teller list outgoings current --output=spark`;
SUM_OUTGOING=`echo "$OUTGOINGS" | sed 's/ /+/g' | bc -l | sed 's/^-//'`;
COUNT_OUTGOING=`echo "$OUTGOINGS" | wc -w | xargs`;
AVERAGE_OUTGOING=`bc <<< "scale=2; $SUM_OUTGOING / $COUNT_OUTGOING"`;

if (( $(bc <<< "$CURRENT_OUTGOING > $AVERAGE_OUTGOING") ))
then
  DIFFERENCE_OUTGOING=`bc <<< "scale=2; $CURRENT_OUTGOING - $AVERAGE_OUTGOING"`;
  echo "You've spent Β£$DIFFERENCE_OUTGOING more than normal." | terminal-notifier -title "πŸ’° Spending Alert" -subtitle "Current Outgoing is Β£$CURRENT_OUTGOING";
fi

Keep track of your spending from the OSX Menu Bar with BitBar

Create a track-spending.1h.sh within your plugins directory:

#!/bin/sh
#
# Teller.io Banking via the OSX menu bar
# Requires:
# - a Teller.io account
# - a UK Bank
# - teller-cli: https://github.com/sebinsua/teller-cli#from-release
# - pcregrep: `brew install pcre`
#
# <bitbar.title>teller-track-spending</bitbar.title>
# <bitbar.version>v1.3.1</bitbar.version>
# <bitbar.author>Seb Insua</bitbar.author>
# <bitbar.author.github>sebinsua</bitbar.author.github>
# <bitbar.desc>Track your spending from your menu bar</bitbar.desc>
# <bitbar.image>https://camo.githubusercontent.com/e0215e6736172334f62effff36ff8df1ab38fed1/687474703a2f2f692e696d6775722e636f6d2f627638545a4c652e706e67</bitbar.image>
# <bitbar.dependencies>teller-cli, pcregrep</bitbar.dependencies>
# <bitbar.abouturl>https://github.com/sebinsua/teller-cli</bitbar.abouturl>

export PATH="/usr/local/bin:/usr/bin/:$PATH";

SPENDING_LIMIT='3000.00'; # Change this to a suitable spending limit.

exit_if_zero() {
  RETURN_CODE=$1;
  ERROR_MESSAGE=$2;
  if [ "$ERROR_MESSAGE" = "" ]; then
    ERROR_MESSAGE="Offline";
  fi;
  if [ "$RETURN_CODE" -ne 0 ]; then
    echo "$ERROR_MESSAGE|color=#7e7e7e";
    exit 1;
  fi;
}

# If we're offline we shouldn't output junk in the menu bar.
curl --connect-timeout 5 www.google.com > /dev/null 2> /dev/null;
exit_if_zero $? "Offline";

CURRENT_OUTGOING=$(teller show outgoing current --hide-currency);
exit_if_zero $? "Error";

CURRENT_BALANCE=$(teller show balance current --hide-currency);
exit_if_zero $? "Error";

LAST_TRANSACTION=$(teller list transactions | tail -n 1 | pcregrep -o1 "[0-9]+[ ]+(.*)");
exit_if_zero $? "Error";

if [ "$(echo "$CURRENT_OUTGOING > $SPENDING_LIMIT" | bc)" -ne 0 ]; then
  OVERSPEND=$(echo "scale=2; $CURRENT_OUTGOING - $SPENDING_LIMIT" | bc);
  echo "🚨 £$OVERSPEND OVERSPENT|color=red";
else
  UNDERSPEND=$(echo "scale=2; $SPENDING_LIMIT - $CURRENT_OUTGOING" | bc);
  if [ "$(echo "$UNDERSPEND > ($SPENDING_LIMIT/2)" | bc)" -ne 0 ]; then
    echo "🏦 £$UNDERSPEND remaining|color=green";
  else
    echo "🏦 £$UNDERSPEND remaining|color=#ffbf00";
  fi;
fi;
echo "---";
echo "Current Account: Β£$CURRENT_BALANCE";
echo "Current Outgoing: Β£$CURRENT_OUTGOING";
echo "Last TX: $LAST_TRANSACTION";

Tracking spending in the OSX Menu Bar

Installation

From release

> curl -L https://github.com/sebinsua/teller-cli/releases/download/v0.0.7/teller > /usr/local/bin/teller && chmod +x /usr/local/bin/teller

From source

First git clone and then:

> cargo build --release && cp ./target/release/teller /usr/local/bin && chmod +x /usr/local/bin/teller

FAQ

Compiling gives openssl/hmac.h not found error

Ensure that both Homebrew and openssl are installed, and then try running brew link --force openssl.

This relates to the following error:

--- stderr
src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found
#include <openssl/hmac.h>

If brew complains about not being able to force-link openssl then you could try building like this:

OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include DEP_OPENSSL_INCLUDE=/usr/local/opt/openssl/include cargo build