From ef2b9342682dd693b203c293520a849c8f3b40c1 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 20 Mar 2019 15:11:22 +0000 Subject: Support retrieving Monzo balance This is intended to be an i3 status bar integration eventually. As long as the monzo_creds file stays encrypted and out of a public GH repository, this should be fairly secure. --- configs/shared/zsh/functions.zsh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'configs/shared') diff --git a/configs/shared/zsh/functions.zsh b/configs/shared/zsh/functions.zsh index 60e512e8fb79..ae259853978b 100644 --- a/configs/shared/zsh/functions.zsh +++ b/configs/shared/zsh/functions.zsh @@ -172,6 +172,26 @@ kush() { } # Misc +monzo_balance() { + # Return the balance of my Monzo bank account. Intended to be used in my i3 + # status bar. + # Usage: monzo_balance + # Depends: + # - ~/Dropbox/monzo_creds.json.gpg (encrypted asymmetrically for yourself) + # - httpie + # - jq + # - gpg + local creds=$(gpg --decrypt ~/Dropbox/monzo_creds.json.gpg 2>/dev/null) + local access_token=$(echo $creds | jq --raw-output .access_token) + local account_id=$(echo $creds | jq --raw-output .account_id) + local balance=$(http --body https://api.monzo.com/balance \ + "Authorization: Bearer ${access_token}" \ + "account_id==${account_id}" | \ + jq .balance) + + echo "£$balance" +} + tldr_docs() { # Helper function for submitting a new page to `tldr`. # Usage: tldr_docs -- cgit 1.4.1